Completed
Push — master ( 02a2d0...8117b3 )
by Fabien
54:58
created
Classes/Thumbnail/ThumbnailConfiguration.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -15,96 +15,96 @@
 block discarded – undo
15 15
 class ThumbnailConfiguration
16 16
 {
17 17
 
18
-    /**
19
-     * @var int
20
-     */
21
-    protected $width = 0;
22
-
23
-    /**
24
-     * @var int
25
-     */
26
-    protected $height = 0;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $style = '';
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $className = '';
37
-
38
-    /**
39
-     * @return int
40
-     */
41
-    public function getWidth()
42
-    {
43
-        return $this->width;
44
-    }
45
-
46
-    /**
47
-     * @param int $width
48
-     * @return $this
49
-     */
50
-    public function setWidth($width)
51
-    {
52
-        $this->width = $width;
53
-        return $this;
54
-    }
55
-
56
-    /**
57
-     * @return int
58
-     */
59
-    public function getHeight()
60
-    {
61
-        return $this->height;
62
-    }
63
-
64
-    /**
65
-     * @param int $height
66
-     * @return $this
67
-     */
68
-    public function setHeight($height)
69
-    {
70
-        $this->height = $height;
71
-        return $this;
72
-    }
73
-
74
-    /**
75
-     * @return string
76
-     */
77
-    public function getStyle()
78
-    {
79
-        return $this->style;
80
-    }
81
-
82
-    /**
83
-     * @param string $style
84
-     * @return $this
85
-     */
86
-    public function setStyle($style)
87
-    {
88
-        $this->style = $style;
89
-        return $this;
90
-    }
91
-
92
-    /**
93
-     * @return string
94
-     */
95
-    public function getClassName()
96
-    {
97
-        return $this->className;
98
-    }
99
-
100
-    /**
101
-     * @param string $className
102
-     * @return $this
103
-     */
104
-    public function setClassName($className)
105
-    {
106
-        $this->className = $className;
107
-        return $this;
108
-    }
18
+	/**
19
+	 * @var int
20
+	 */
21
+	protected $width = 0;
22
+
23
+	/**
24
+	 * @var int
25
+	 */
26
+	protected $height = 0;
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $style = '';
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $className = '';
37
+
38
+	/**
39
+	 * @return int
40
+	 */
41
+	public function getWidth()
42
+	{
43
+		return $this->width;
44
+	}
45
+
46
+	/**
47
+	 * @param int $width
48
+	 * @return $this
49
+	 */
50
+	public function setWidth($width)
51
+	{
52
+		$this->width = $width;
53
+		return $this;
54
+	}
55
+
56
+	/**
57
+	 * @return int
58
+	 */
59
+	public function getHeight()
60
+	{
61
+		return $this->height;
62
+	}
63
+
64
+	/**
65
+	 * @param int $height
66
+	 * @return $this
67
+	 */
68
+	public function setHeight($height)
69
+	{
70
+		$this->height = $height;
71
+		return $this;
72
+	}
73
+
74
+	/**
75
+	 * @return string
76
+	 */
77
+	public function getStyle()
78
+	{
79
+		return $this->style;
80
+	}
81
+
82
+	/**
83
+	 * @param string $style
84
+	 * @return $this
85
+	 */
86
+	public function setStyle($style)
87
+	{
88
+		$this->style = $style;
89
+		return $this;
90
+	}
91
+
92
+	/**
93
+	 * @return string
94
+	 */
95
+	public function getClassName()
96
+	{
97
+		return $this->className;
98
+	}
99
+
100
+	/**
101
+	 * @param string $className
102
+	 * @return $this
103
+	 */
104
+	public function setClassName($className)
105
+	{
106
+		$this->className = $className;
107
+		return $this;
108
+	}
109 109
 
110 110
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/AudioThumbnailProcessor.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -17,96 +17,96 @@
 block discarded – undo
17 17
 class AudioThumbnailProcessor extends AbstractThumbnailProcessor
18 18
 {
19 19
 
20
-    /**
21
-     * Render a thumbnail of a resource of type audio.
22
-     *
23
-     * @return string
24
-     */
25
-    public function create()
26
-    {
27
-        $steps = $this->getRenderingSteps();
28
-
29
-        $result = '';
30
-        while ($step = array_shift($steps)) {
31
-            $result = $this->$step($result);
32
-        }
33
-
34
-        return $result;
35
-    }
36
-
37
-    /**
38
-     * Render the URI of the thumbnail.
39
-     *
40
-     * @return string
41
-     */
42
-    public function renderUri()
43
-    {
44
-
45
-        $relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
-        $fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
47
-        if (!file_exists($fileNameAndPath)) {
48
-            $relativePath = 'Icons/UnknownMimeType.png';
49
-        }
50
-
51
-        $uri = Path::getRelativePath($relativePath);
52
-        return $this->prefixUri($uri);
53
-    }
54
-
55
-    /**
56
-     * Render the tag image which is the main one for a thumbnail.
57
-     *
58
-     * @param string $result
59
-     * @return string
60
-     */
61
-    public function renderTagImage($result)
62
-    {
63
-
64
-        // Variable $result corresponds to an URL in this case.
65
-        // Analyse the URL and compute the adequate separator between arguments.
66
-        $parameterSeparator = strpos($result, '?') === false ? '?' : '&';
67
-
68
-        return sprintf(
69
-            '<img src="%s%s" title="%s" alt="%s" %s/>',
70
-            $result,
71
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getFile()->getProperty('tstamp') : '',
72
-            $this->getTitle(),
73
-            $this->getTitle(),
74
-            $this->renderAttributes()
75
-        );
76
-    }
77
-
78
-    /**
79
-     * Compute and return the title of the file.
80
-     *
81
-     * @return string
82
-     */
83
-    protected function getTitle()
84
-    {
85
-        $result = $this->getFile()->getProperty('title');
86
-        if (!$result) {
87
-            $result = $this->getFile()->getName();
88
-        }
89
-        return htmlspecialchars($result);
90
-    }
91
-
92
-    /**
93
-     * Render a wrapping anchor around the thumbnail.
94
-     *
95
-     * @param string $result
96
-     * @return string
97
-     */
98
-    public function renderTagAnchor($result)
99
-    {
100
-
101
-        $file = $this->getFile();
102
-
103
-        return sprintf(
104
-            '<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105
-            $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
-            $this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
107
-            $this->thumbnailService->getTarget(),
108
-            $file->getUid(),
109
-            $result
110
-        );
111
-    }
20
+	/**
21
+	 * Render a thumbnail of a resource of type audio.
22
+	 *
23
+	 * @return string
24
+	 */
25
+	public function create()
26
+	{
27
+		$steps = $this->getRenderingSteps();
28
+
29
+		$result = '';
30
+		while ($step = array_shift($steps)) {
31
+			$result = $this->$step($result);
32
+		}
33
+
34
+		return $result;
35
+	}
36
+
37
+	/**
38
+	 * Render the URI of the thumbnail.
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public function renderUri()
43
+	{
44
+
45
+		$relativePath = sprintf('Icons/MimeType/%s.png', $this->getFile()->getProperty('extension'));
46
+		$fileNameAndPath = GeneralUtility::getFileAbsFileName('EXT:media/Resources/Public/' . $relativePath);
47
+		if (!file_exists($fileNameAndPath)) {
48
+			$relativePath = 'Icons/UnknownMimeType.png';
49
+		}
50
+
51
+		$uri = Path::getRelativePath($relativePath);
52
+		return $this->prefixUri($uri);
53
+	}
54
+
55
+	/**
56
+	 * Render the tag image which is the main one for a thumbnail.
57
+	 *
58
+	 * @param string $result
59
+	 * @return string
60
+	 */
61
+	public function renderTagImage($result)
62
+	{
63
+
64
+		// Variable $result corresponds to an URL in this case.
65
+		// Analyse the URL and compute the adequate separator between arguments.
66
+		$parameterSeparator = strpos($result, '?') === false ? '?' : '&';
67
+
68
+		return sprintf(
69
+			'<img src="%s%s" title="%s" alt="%s" %s/>',
70
+			$result,
71
+			$this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getFile()->getProperty('tstamp') : '',
72
+			$this->getTitle(),
73
+			$this->getTitle(),
74
+			$this->renderAttributes()
75
+		);
76
+	}
77
+
78
+	/**
79
+	 * Compute and return the title of the file.
80
+	 *
81
+	 * @return string
82
+	 */
83
+	protected function getTitle()
84
+	{
85
+		$result = $this->getFile()->getProperty('title');
86
+		if (!$result) {
87
+			$result = $this->getFile()->getName();
88
+		}
89
+		return htmlspecialchars($result);
90
+	}
91
+
92
+	/**
93
+	 * Render a wrapping anchor around the thumbnail.
94
+	 *
95
+	 * @param string $result
96
+	 * @return string
97
+	 */
98
+	public function renderTagAnchor($result)
99
+	{
100
+
101
+		$file = $this->getFile();
102
+
103
+		return sprintf(
104
+			'<a href="%s%s" target="%s" data-uid="%s">%s</a>',
105
+			$this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true),
106
+			$this->thumbnailService->getAppendTimeStamp() ? '?' . $file->getProperty('tstamp') : '',
107
+			$this->thumbnailService->getTarget(),
108
+			$file->getUid(),
109
+			$result
110
+		);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/ApplicationThumbnailProcessor.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -18,140 +18,140 @@
 block discarded – undo
18 18
 class ApplicationThumbnailProcessor extends AbstractThumbnailProcessor
19 19
 {
20 20
 
21
-    /**
22
-     * Render a thumbnail of a resource of type application.
23
-     *
24
-     * @return string
25
-     */
26
-    public function create()
27
-    {
28
-
29
-        $steps = $this->getRenderingSteps();
30
-
31
-        $result = '';
32
-        while ($step = array_shift($steps)) {
33
-            $result = $this->$step($result);
34
-        }
35
-
36
-        return $result;
37
-    }
38
-
39
-    /**
40
-     * Render the URI of the thumbnail.
41
-     *
42
-     * @return string
43
-     */
44
-    public function renderUri()
45
-    {
46
-        if ($this->isThumbnailPossible($this->getFile()->getExtension())) {
47
-            $this->processedFile = $this->getFile()->process($this->getProcessingType(), $this->getConfiguration());
48
-            $uri = $this->processedFile->getPublicUrl(true);
49
-
50
-            // Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
51
-            if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
52
-                $this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
53
-            }
54
-        } else {
55
-            $uri = $this->getIcon($this->getFile()->getExtension());
56
-        }
57
-        return $this->prefixUri($uri);
58
-    }
59
-
60
-    /**
61
-     * Render the tag image which is the main one for a thumbnail.
62
-     *
63
-     * @param string $result
64
-     * @return string
65
-     */
66
-    public function renderTagImage($result)
67
-    {
68
-
69
-        // Variable $result corresponds to an URL in this case.
70
-        // Analyse the URL and compute the adequate separator between arguments.
71
-        $parameterSeparator = strpos($result, '?') === false ? '?' : '&';
72
-
73
-        return sprintf(
74
-            '<img src="%s%s" title="%s" alt="%s" %s/>',
75
-            $result,
76
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '',
77
-            $this->getTitle(),
78
-            $this->getTitle(),
79
-            $this->renderAttributes()
80
-        );
81
-    }
82
-
83
-    /**
84
-     * Compute and return the time stamp.
85
-     *
86
-     * @return int
87
-     */
88
-    protected function getTimeStamp()
89
-    {
90
-        $result = $this->getFile()->getProperty('tstamp');
91
-        if ($this->processedFile) {
92
-            $result = $this->processedFile->getProperty('tstamp');
93
-        }
94
-        return $result;
95
-    }
96
-
97
-    /**
98
-     * Compute and return the title of the file.
99
-     *
100
-     * @return string
101
-     */
102
-    protected function getTitle()
103
-    {
104
-        $result = $this->getFile()->getProperty('title');
105
-        if (empty($result)) {
106
-            $result = $this->getFile()->getName();
107
-        }
108
-        return htmlspecialchars($result);
109
-    }
110
-
111
-    /**
112
-     * Render a wrapping anchor around the thumbnail.
113
-     *
114
-     * @param string $result
115
-     * @return string
116
-     */
117
-    public function renderTagAnchor($result)
118
-    {
119
-        $uri = $this->thumbnailService->getAnchorUri();
120
-        if (!$uri) {
121
-            $uri = $this->getUri();
122
-        }
123
-
124
-        return sprintf(
125
-            '<a href="%s" target="_blank" data-uid="%s">%s</a>',
126
-            $uri,
127
-            $this->getFile()->getUid(),
128
-            $result
129
-        );
130
-    }
131
-
132
-    /**
133
-     * @return string
134
-     */
135
-    protected function getUri()
136
-    {
137
-        $urlParameters = array(
138
-            MediaModule::getParameterPrefix() => [
139
-                'controller' => 'Asset',
140
-                'action' => 'download',
141
-                'file' => $this->getFile()->getUid(),
142
-            ],
143
-        );
144
-        return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
145
-    }
146
-
147
-    /**
148
-     * @return string
149
-     */
150
-    public function getProcessingType()
151
-    {
152
-        if ($this->thumbnailService->getProcessingType() === null) {
153
-            return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
154
-        }
155
-        return $this->thumbnailService->getProcessingType();
156
-    }
21
+	/**
22
+	 * Render a thumbnail of a resource of type application.
23
+	 *
24
+	 * @return string
25
+	 */
26
+	public function create()
27
+	{
28
+
29
+		$steps = $this->getRenderingSteps();
30
+
31
+		$result = '';
32
+		while ($step = array_shift($steps)) {
33
+			$result = $this->$step($result);
34
+		}
35
+
36
+		return $result;
37
+	}
38
+
39
+	/**
40
+	 * Render the URI of the thumbnail.
41
+	 *
42
+	 * @return string
43
+	 */
44
+	public function renderUri()
45
+	{
46
+		if ($this->isThumbnailPossible($this->getFile()->getExtension())) {
47
+			$this->processedFile = $this->getFile()->process($this->getProcessingType(), $this->getConfiguration());
48
+			$uri = $this->processedFile->getPublicUrl(true);
49
+
50
+			// Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
51
+			if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
52
+				$this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
53
+			}
54
+		} else {
55
+			$uri = $this->getIcon($this->getFile()->getExtension());
56
+		}
57
+		return $this->prefixUri($uri);
58
+	}
59
+
60
+	/**
61
+	 * Render the tag image which is the main one for a thumbnail.
62
+	 *
63
+	 * @param string $result
64
+	 * @return string
65
+	 */
66
+	public function renderTagImage($result)
67
+	{
68
+
69
+		// Variable $result corresponds to an URL in this case.
70
+		// Analyse the URL and compute the adequate separator between arguments.
71
+		$parameterSeparator = strpos($result, '?') === false ? '?' : '&';
72
+
73
+		return sprintf(
74
+			'<img src="%s%s" title="%s" alt="%s" %s/>',
75
+			$result,
76
+			$this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->getTimeStamp() : '',
77
+			$this->getTitle(),
78
+			$this->getTitle(),
79
+			$this->renderAttributes()
80
+		);
81
+	}
82
+
83
+	/**
84
+	 * Compute and return the time stamp.
85
+	 *
86
+	 * @return int
87
+	 */
88
+	protected function getTimeStamp()
89
+	{
90
+		$result = $this->getFile()->getProperty('tstamp');
91
+		if ($this->processedFile) {
92
+			$result = $this->processedFile->getProperty('tstamp');
93
+		}
94
+		return $result;
95
+	}
96
+
97
+	/**
98
+	 * Compute and return the title of the file.
99
+	 *
100
+	 * @return string
101
+	 */
102
+	protected function getTitle()
103
+	{
104
+		$result = $this->getFile()->getProperty('title');
105
+		if (empty($result)) {
106
+			$result = $this->getFile()->getName();
107
+		}
108
+		return htmlspecialchars($result);
109
+	}
110
+
111
+	/**
112
+	 * Render a wrapping anchor around the thumbnail.
113
+	 *
114
+	 * @param string $result
115
+	 * @return string
116
+	 */
117
+	public function renderTagAnchor($result)
118
+	{
119
+		$uri = $this->thumbnailService->getAnchorUri();
120
+		if (!$uri) {
121
+			$uri = $this->getUri();
122
+		}
123
+
124
+		return sprintf(
125
+			'<a href="%s" target="_blank" data-uid="%s">%s</a>',
126
+			$uri,
127
+			$this->getFile()->getUid(),
128
+			$result
129
+		);
130
+	}
131
+
132
+	/**
133
+	 * @return string
134
+	 */
135
+	protected function getUri()
136
+	{
137
+		$urlParameters = array(
138
+			MediaModule::getParameterPrefix() => [
139
+				'controller' => 'Asset',
140
+				'action' => 'download',
141
+				'file' => $this->getFile()->getUid(),
142
+			],
143
+		);
144
+		return BackendUtility::getModuleUrl(MediaModule::getSignature(), $urlParameters);
145
+	}
146
+
147
+	/**
148
+	 * @return string
149
+	 */
150
+	public function getProcessingType()
151
+	{
152
+		if ($this->thumbnailService->getProcessingType() === null) {
153
+			return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
154
+		}
155
+		return $this->thumbnailService->getProcessingType();
156
+	}
157 157
 }
Please login to merge, or discard this patch.
Classes/Thumbnail/ImageThumbnailProcessor.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -16,180 +16,180 @@
 block discarded – undo
16 16
 class ImageThumbnailProcessor extends AbstractThumbnailProcessor
17 17
 {
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    protected $defaultConfigurationWrap = array(
23
-        'width' => 0,
24
-        'height' => 0,
25
-    );
26
-
27
-    /**
28
-     * Render a thumbnail of a resource of type image.
29
-     *
30
-     * @return string
31
-     */
32
-    public function create()
33
-    {
34
-        $steps = $this->getRenderingSteps();
35
-
36
-        $result = '';
37
-        while ($step = array_shift($steps)) {
38
-            $result = $this->$step($result);
39
-        }
40
-
41
-        return $result;
42
-    }
43
-
44
-    /**
45
-     * Render the URI of the thumbnail.
46
-     *
47
-     * @return string
48
-     * @throws \Fab\Media\Exception\EmptyValueException
49
-     */
50
-    public function renderUri()
51
-    {
52
-
53
-        // Makes sure the width and the height of the thumbnail is not bigger than the actual file
54
-        $configuration = $this->getConfiguration();
55
-        if (!empty($configuration['width']) && $configuration['width'] > $this->getFile()->getProperty('width')) {
56
-            $configuration['width'] = $this->getFile()->getProperty('width');
57
-        }
58
-        if (!empty($configuration['height']) && $configuration['height'] > $this->getFile()->getProperty('height')) {
59
-            $configuration['height'] = $this->getFile()->getProperty('height');
60
-        }
61
-
62
-        $configuration = $this->computeFinalImageDimension($configuration);
63
-        $this->processedFile = $this->getFile()->process($this->getProcessingType(), $configuration);
64
-        $uri = $this->processedFile->getPublicUrl(true);
65
-
66
-        // Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
67
-        if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
68
-            $this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
69
-        }
70
-
71
-        return $this->prefixUri($uri);
72
-    }
73
-
74
-    /**
75
-     * Render the tag image which is the main one for a thumbnail.
76
-     *
77
-     * @param string $result
78
-     * @return string
79
-     */
80
-    public function renderTagImage($result)
81
-    {
82
-
83
-        // Variable $result corresponds to an URL in this case.
84
-        // Analyse the URL and compute the adequate separator between arguments.
85
-        $parameterSeparator = strpos($result, '?') === false ? '?' : '&';
86
-
87
-        return sprintf('<img src="%s%s" title="%s" alt="%s" %s/>',
88
-            $result,
89
-            $this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->processedFile->getProperty('tstamp') : '',
90
-            $this->getTitle(),
91
-            $this->getTitle(),
92
-            $this->renderAttributes()
93
-        );
94
-    }
95
-
96
-    /**
97
-     * Compute and return the title of the file.
98
-     *
99
-     * @return string
100
-     */
101
-    protected function getTitle()
102
-    {
103
-        $result = $this->getFile()->getProperty('title');
104
-        if (!$result) {
105
-            $result = $this->getFile()->getName();
106
-        }
107
-        return htmlspecialchars($result);
108
-    }
109
-
110
-    /**
111
-     * Render a wrapping anchor around the thumbnail.
112
-     *
113
-     * @param string $result
114
-     * @return string
115
-     */
116
-    public function renderTagAnchor($result)
117
-    {
118
-
119
-        $file = $this->getFile();
120
-
121
-        // Perhaps the wrapping file must be processed
122
-        $configurationWrap = $this->thumbnailService->getConfigurationWrap();
123
-
124
-        // Make sure we have configurationWrap initialized correctly
125
-        if (!empty($configurationWrap['width']) || !empty($configurationWrap['height'])) {
126
-            $configurationWrap = array_merge($this->defaultConfigurationWrap, $configurationWrap);
127
-
128
-            // It looks maxW or maxH does not work as expected with CONTEXT_IMAGEPREVIEW...
129
-            // ... uses "width" and "height" instead.
130
-            if ($configurationWrap['width'] < $this->getFile()->getProperty('width')
131
-                || $configurationWrap['height'] < $this->getFile()->getProperty('height')
132
-            ) {
133
-                $configurationWrap = $this->computeFinalImageDimension($configurationWrap);
134
-                $file = $this->getFile()->process($this->getProcessingType(), $configurationWrap);
135
-            }
136
-        }
137
-
138
-        // Analyse the current $url and compute the adequate separator between arguments.
139
-        $url = $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true);
140
-        $parameterSeparator = strpos($url, '?') === false ? '?' : '&';
141
-
142
-        return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
143
-            $url,
144
-            $this->thumbnailService->getAppendTimeStamp() && !$this->thumbnailService->getAnchorUri() ? $parameterSeparator . $file->getProperty('tstamp') : '',
145
-            $this->thumbnailService->getTarget(),
146
-            $file->getUid(),
147
-            $result
148
-        );
149
-    }
150
-
151
-    /**
152
-     * Compute the final configuration for the image preview.
153
-     * Keep ratio of width / height for the image.
154
-     *
155
-     * @param array $configuration
156
-     * @return array
157
-     */
158
-    protected function computeFinalImageDimension(array $configuration)
159
-    {
160
-        $ratio = $this->computeImageRatio();
161
-
162
-        if ($ratio > 1) {
163
-            $configuration['height'] = round($configuration['width'] / $ratio);
164
-        } else {
165
-            $configuration['width'] = round($configuration['height'] * $ratio);
166
-        }
167
-        return $configuration;
168
-    }
169
-
170
-    /**
171
-     * Compute the width / height ratio of the image.
172
-     *
173
-     * @return null|float
174
-     */
175
-    protected function computeImageRatio()
176
-    {
177
-        $ratio = null;
178
-        if ($this->getFile()->getProperty('width') > 0 && $this->getFile()->getProperty('height') > 0) {
179
-            $ratio = $this->getFile()->getProperty('width') / $this->getFile()->getProperty('height');
180
-        }
181
-        return $ratio;
182
-    }
183
-
184
-    /**
185
-     * @return string
186
-     */
187
-    public function getProcessingType()
188
-    {
189
-        if ($this->thumbnailService->getProcessingType() === null) {
190
-            return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
191
-        }
192
-        return $this->thumbnailService->getProcessingType();
193
-    }
19
+	/**
20
+	 * @var array
21
+	 */
22
+	protected $defaultConfigurationWrap = array(
23
+		'width' => 0,
24
+		'height' => 0,
25
+	);
26
+
27
+	/**
28
+	 * Render a thumbnail of a resource of type image.
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function create()
33
+	{
34
+		$steps = $this->getRenderingSteps();
35
+
36
+		$result = '';
37
+		while ($step = array_shift($steps)) {
38
+			$result = $this->$step($result);
39
+		}
40
+
41
+		return $result;
42
+	}
43
+
44
+	/**
45
+	 * Render the URI of the thumbnail.
46
+	 *
47
+	 * @return string
48
+	 * @throws \Fab\Media\Exception\EmptyValueException
49
+	 */
50
+	public function renderUri()
51
+	{
52
+
53
+		// Makes sure the width and the height of the thumbnail is not bigger than the actual file
54
+		$configuration = $this->getConfiguration();
55
+		if (!empty($configuration['width']) && $configuration['width'] > $this->getFile()->getProperty('width')) {
56
+			$configuration['width'] = $this->getFile()->getProperty('width');
57
+		}
58
+		if (!empty($configuration['height']) && $configuration['height'] > $this->getFile()->getProperty('height')) {
59
+			$configuration['height'] = $this->getFile()->getProperty('height');
60
+		}
61
+
62
+		$configuration = $this->computeFinalImageDimension($configuration);
63
+		$this->processedFile = $this->getFile()->process($this->getProcessingType(), $configuration);
64
+		$uri = $this->processedFile->getPublicUrl(true);
65
+
66
+		// Update time stamp of processed image at this stage. This is needed for the browser to get new version of the thumbnail.
67
+		if ($this->processedFile->getProperty('originalfilesha1') !== $this->getFile()->getProperty('sha1')) {
68
+			$this->processedFile->updateProperties(array('tstamp' => $this->getFile()->getProperty('tstamp')));
69
+		}
70
+
71
+		return $this->prefixUri($uri);
72
+	}
73
+
74
+	/**
75
+	 * Render the tag image which is the main one for a thumbnail.
76
+	 *
77
+	 * @param string $result
78
+	 * @return string
79
+	 */
80
+	public function renderTagImage($result)
81
+	{
82
+
83
+		// Variable $result corresponds to an URL in this case.
84
+		// Analyse the URL and compute the adequate separator between arguments.
85
+		$parameterSeparator = strpos($result, '?') === false ? '?' : '&';
86
+
87
+		return sprintf('<img src="%s%s" title="%s" alt="%s" %s/>',
88
+			$result,
89
+			$this->thumbnailService->getAppendTimeStamp() ? $parameterSeparator . $this->processedFile->getProperty('tstamp') : '',
90
+			$this->getTitle(),
91
+			$this->getTitle(),
92
+			$this->renderAttributes()
93
+		);
94
+	}
95
+
96
+	/**
97
+	 * Compute and return the title of the file.
98
+	 *
99
+	 * @return string
100
+	 */
101
+	protected function getTitle()
102
+	{
103
+		$result = $this->getFile()->getProperty('title');
104
+		if (!$result) {
105
+			$result = $this->getFile()->getName();
106
+		}
107
+		return htmlspecialchars($result);
108
+	}
109
+
110
+	/**
111
+	 * Render a wrapping anchor around the thumbnail.
112
+	 *
113
+	 * @param string $result
114
+	 * @return string
115
+	 */
116
+	public function renderTagAnchor($result)
117
+	{
118
+
119
+		$file = $this->getFile();
120
+
121
+		// Perhaps the wrapping file must be processed
122
+		$configurationWrap = $this->thumbnailService->getConfigurationWrap();
123
+
124
+		// Make sure we have configurationWrap initialized correctly
125
+		if (!empty($configurationWrap['width']) || !empty($configurationWrap['height'])) {
126
+			$configurationWrap = array_merge($this->defaultConfigurationWrap, $configurationWrap);
127
+
128
+			// It looks maxW or maxH does not work as expected with CONTEXT_IMAGEPREVIEW...
129
+			// ... uses "width" and "height" instead.
130
+			if ($configurationWrap['width'] < $this->getFile()->getProperty('width')
131
+				|| $configurationWrap['height'] < $this->getFile()->getProperty('height')
132
+			) {
133
+				$configurationWrap = $this->computeFinalImageDimension($configurationWrap);
134
+				$file = $this->getFile()->process($this->getProcessingType(), $configurationWrap);
135
+			}
136
+		}
137
+
138
+		// Analyse the current $url and compute the adequate separator between arguments.
139
+		$url = $this->thumbnailService->getAnchorUri() ? $this->thumbnailService->getAnchorUri() : $file->getPublicUrl(true);
140
+		$parameterSeparator = strpos($url, '?') === false ? '?' : '&';
141
+
142
+		return sprintf('<a href="%s%s" target="%s" data-uid="%s">%s</a>',
143
+			$url,
144
+			$this->thumbnailService->getAppendTimeStamp() && !$this->thumbnailService->getAnchorUri() ? $parameterSeparator . $file->getProperty('tstamp') : '',
145
+			$this->thumbnailService->getTarget(),
146
+			$file->getUid(),
147
+			$result
148
+		);
149
+	}
150
+
151
+	/**
152
+	 * Compute the final configuration for the image preview.
153
+	 * Keep ratio of width / height for the image.
154
+	 *
155
+	 * @param array $configuration
156
+	 * @return array
157
+	 */
158
+	protected function computeFinalImageDimension(array $configuration)
159
+	{
160
+		$ratio = $this->computeImageRatio();
161
+
162
+		if ($ratio > 1) {
163
+			$configuration['height'] = round($configuration['width'] / $ratio);
164
+		} else {
165
+			$configuration['width'] = round($configuration['height'] * $ratio);
166
+		}
167
+		return $configuration;
168
+	}
169
+
170
+	/**
171
+	 * Compute the width / height ratio of the image.
172
+	 *
173
+	 * @return null|float
174
+	 */
175
+	protected function computeImageRatio()
176
+	{
177
+		$ratio = null;
178
+		if ($this->getFile()->getProperty('width') > 0 && $this->getFile()->getProperty('height') > 0) {
179
+			$ratio = $this->getFile()->getProperty('width') / $this->getFile()->getProperty('height');
180
+		}
181
+		return $ratio;
182
+	}
183
+
184
+	/**
185
+	 * @return string
186
+	 */
187
+	public function getProcessingType()
188
+	{
189
+		if ($this->thumbnailService->getProcessingType() === null) {
190
+			return ProcessedFile::CONTEXT_IMAGECROPSCALEMASK;
191
+		}
192
+		return $this->thumbnailService->getProcessingType();
193
+	}
194 194
 
195 195
 }
Please login to merge, or discard this patch.
Classes/Dimension.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@
 block discarded – undo
16 16
 class Dimension
17 17
 {
18 18
 
19
-    /**
20
-     * @var int
21
-     */
22
-    protected $width = 0;
23
-
24
-    /**
25
-     * @var int
26
-     */
27
-    protected $height = 0;
28
-
29
-    /**
30
-     * @param string $dimension
31
-     */
32
-    public function __construct($dimension)
33
-    {
34
-        $dimensions = GeneralUtility::trimExplode('x', $dimension);
35
-        $this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
-        $this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
-    }
38
-
39
-    /**
40
-     * @return mixed
41
-     */
42
-    public function getWidth()
43
-    {
44
-        return $this->width;
45
-    }
46
-
47
-    /**
48
-     * @return int
49
-     */
50
-    public function getHeight()
51
-    {
52
-        return $this->height;
53
-    }
19
+	/**
20
+	 * @var int
21
+	 */
22
+	protected $width = 0;
23
+
24
+	/**
25
+	 * @var int
26
+	 */
27
+	protected $height = 0;
28
+
29
+	/**
30
+	 * @param string $dimension
31
+	 */
32
+	public function __construct($dimension)
33
+	{
34
+		$dimensions = GeneralUtility::trimExplode('x', $dimension);
35
+		$this->width = empty($dimensions[0]) ? 0 : $dimensions[0];
36
+		$this->height = empty($dimensions[1]) ? 0 : $dimensions[1];
37
+	}
38
+
39
+	/**
40
+	 * @return mixed
41
+	 */
42
+	public function getWidth()
43
+	{
44
+		return $this->width;
45
+	}
46
+
47
+	/**
48
+	 * @return int
49
+	 */
50
+	public function getHeight()
51
+	{
52
+		return $this->height;
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Classes/Form/AbstractFormField.php 1 patch
Indentation   +262 added lines, -262 removed lines patch added patch discarded remove patch
@@ -18,267 +18,267 @@
 block discarded – undo
18 18
 abstract class AbstractFormField implements FormFieldInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $template = '';
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    protected $value = '';
30
-
31
-    /**
32
-     * @var string
33
-     */
34
-    protected $name = '';
35
-
36
-    /**
37
-     * @var string
38
-     */
39
-    protected $id = '';
40
-
41
-    /**
42
-     * @var string
43
-     */
44
-    protected $prefix = '';
45
-
46
-    /**
47
-     * @var string
48
-     */
49
-    protected $label = '';
50
-
51
-    /**
52
-     * Store what child element will contain this element.
53
-     *
54
-     * @var array
55
-     */
56
-    protected $items = [];
57
-
58
-    /**
59
-     * Attributes in sense of DOM attribute, e.g. class, style, etc...
60
-     *
61
-     * @var array
62
-     */
63
-    protected $attributes = [];
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function render()
69
-    {
70
-        return $this->template;
71
-    }
72
-
73
-    /**
74
-     * Render the label if possible. Otherwise return an empty string.
75
-     *
76
-     * @return string
77
-     */
78
-    public function renderLabel()
79
-    {
80
-        $result = '';
81
-        if ($this->label) {
82
-            $template = '<label class="control-label" for="%s">%s</label>';
83
-
84
-            if (strpos($this->label, 'LLL:') === 0) {
85
-                $this->label = LocalizationUtility::translate($this->label, '');
86
-            }
87
-
88
-            $result = sprintf($template,
89
-                $this->getId(),
90
-                $this->label
91
-            );
92
-        }
93
-        return $result;
94
-    }
95
-
96
-    /**
97
-     * Render additional attribute for this DOM element.
98
-     *
99
-     * @return string
100
-     */
101
-    public function renderAttributes()
102
-    {
103
-        $result = '';
104
-        if (!empty($this->attributes)) {
105
-            foreach ($this->attributes as $attribute => $value) {
106
-                $result .= sprintf('%s="%s" ',
107
-                    htmlspecialchars($attribute),
108
-                    htmlspecialchars($value)
109
-                );
110
-            }
111
-        }
112
-        return $result;
113
-    }
114
-
115
-    /**
116
-     * Add an additional (DOM) attribute to be added to this template.
117
-     *
118
-     * @throws InvalidStringException
119
-     * @param array $attribute associative array that contains attribute => value
120
-     * @return \Fab\Media\Form\AbstractFormField
121
-     */
122
-    public function addAttribute(array $attribute)
123
-    {
124
-        if (!empty($attribute)) {
125
-            reset($attribute);
126
-            $key = key($attribute);
127
-            if (!is_string($key)) {
128
-                throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
129
-            }
130
-
131
-            $this->attributes[$key] = $attribute[$key];
132
-        }
133
-        return $this;
134
-    }
135
-
136
-    /**
137
-     * @return string
138
-     */
139
-    public function getTemplate()
140
-    {
141
-        return $this->template;
142
-    }
143
-
144
-    /**
145
-     * @param string $template
146
-     * @return \Fab\Media\Form\AbstractFormField
147
-     */
148
-    public function setTemplate($template)
149
-    {
150
-        $this->template = $template;
151
-    }
152
-
153
-    /**
154
-     * @return string
155
-     */
156
-    public function getLabel()
157
-    {
158
-        return $this->label;
159
-    }
160
-
161
-    /**
162
-     * @param string $label
163
-     * @return \Fab\Media\Form\AbstractFormField
164
-     */
165
-    public function setLabel($label)
166
-    {
167
-        $this->label = $label;
168
-        return $this;
169
-    }
170
-
171
-    /**
172
-     * @return string
173
-     */
174
-    public function getPrefix()
175
-    {
176
-        return $this->prefix;
177
-    }
178
-
179
-    /**
180
-     * @param string $prefix
181
-     * @return \Fab\Media\Form\AbstractFormField
182
-     */
183
-    public function setPrefix($prefix)
184
-    {
185
-        $this->prefix = $prefix;
186
-        return $this;
187
-    }
188
-
189
-    /**
190
-     * @return array
191
-     */
192
-    public function getItems()
193
-    {
194
-        return $this->items;
195
-    }
196
-
197
-    /**
198
-     * @param array $items
199
-     */
200
-    public function setItems($items)
201
-    {
202
-        $this->items = $items;
203
-    }
204
-
205
-    /**
206
-     * @return string
207
-     */
208
-    public function getValue()
209
-    {
210
-        return htmlspecialchars($this->value);
211
-    }
212
-
213
-    /**
214
-     * @param string $value
215
-     * @return \Fab\Media\Form\AbstractFormField
216
-     */
217
-    public function setValue($value)
218
-    {
219
-        $this->value = $value;
220
-        return $this;
221
-    }
222
-
223
-    /**
224
-     * @return string
225
-     */
226
-    public function getName()
227
-    {
228
-        $result = $this->name;
229
-        if ($this->getPrefix()) {
230
-            $result = sprintf('%s[%s]', $this->getPrefix(), $this->name);
231
-        }
232
-        return $result;
233
-    }
234
-
235
-    /**
236
-     * @param string $name
237
-     * @return \Fab\Media\Form\AbstractFormField
238
-     */
239
-    public function setName($name)
240
-    {
241
-        $this->name = $name;
242
-        return $this;
243
-    }
244
-
245
-    /**
246
-     * @return string
247
-     */
248
-    public function getId()
249
-    {
250
-        if ($this->id === '') {
251
-            $this->id = DomElement::getInstance()->formatId($this->getName());
252
-        }
253
-        return $this->id;
254
-    }
255
-
256
-    /**
257
-     * @param string $id
258
-     * @return \Fab\Media\Form\AbstractFormField
259
-     */
260
-    public function setId($id)
261
-    {
262
-        $this->id = $id;
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * @return array
268
-     */
269
-    public function getAttributes()
270
-    {
271
-        return $this->attributes;
272
-    }
273
-
274
-    /**
275
-     * @param array $attributes
276
-     * @return \Fab\Media\Form\AbstractFormField
277
-     */
278
-    public function setAttributes($attributes)
279
-    {
280
-        $this->attributes = $attributes;
281
-        return $this;
282
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $template = '';
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected $value = '';
30
+
31
+	/**
32
+	 * @var string
33
+	 */
34
+	protected $name = '';
35
+
36
+	/**
37
+	 * @var string
38
+	 */
39
+	protected $id = '';
40
+
41
+	/**
42
+	 * @var string
43
+	 */
44
+	protected $prefix = '';
45
+
46
+	/**
47
+	 * @var string
48
+	 */
49
+	protected $label = '';
50
+
51
+	/**
52
+	 * Store what child element will contain this element.
53
+	 *
54
+	 * @var array
55
+	 */
56
+	protected $items = [];
57
+
58
+	/**
59
+	 * Attributes in sense of DOM attribute, e.g. class, style, etc...
60
+	 *
61
+	 * @var array
62
+	 */
63
+	protected $attributes = [];
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function render()
69
+	{
70
+		return $this->template;
71
+	}
72
+
73
+	/**
74
+	 * Render the label if possible. Otherwise return an empty string.
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public function renderLabel()
79
+	{
80
+		$result = '';
81
+		if ($this->label) {
82
+			$template = '<label class="control-label" for="%s">%s</label>';
83
+
84
+			if (strpos($this->label, 'LLL:') === 0) {
85
+				$this->label = LocalizationUtility::translate($this->label, '');
86
+			}
87
+
88
+			$result = sprintf($template,
89
+				$this->getId(),
90
+				$this->label
91
+			);
92
+		}
93
+		return $result;
94
+	}
95
+
96
+	/**
97
+	 * Render additional attribute for this DOM element.
98
+	 *
99
+	 * @return string
100
+	 */
101
+	public function renderAttributes()
102
+	{
103
+		$result = '';
104
+		if (!empty($this->attributes)) {
105
+			foreach ($this->attributes as $attribute => $value) {
106
+				$result .= sprintf('%s="%s" ',
107
+					htmlspecialchars($attribute),
108
+					htmlspecialchars($value)
109
+				);
110
+			}
111
+		}
112
+		return $result;
113
+	}
114
+
115
+	/**
116
+	 * Add an additional (DOM) attribute to be added to this template.
117
+	 *
118
+	 * @throws InvalidStringException
119
+	 * @param array $attribute associative array that contains attribute => value
120
+	 * @return \Fab\Media\Form\AbstractFormField
121
+	 */
122
+	public function addAttribute(array $attribute)
123
+	{
124
+		if (!empty($attribute)) {
125
+			reset($attribute);
126
+			$key = key($attribute);
127
+			if (!is_string($key)) {
128
+				throw new InvalidStringException('Not an associative array. Is not a key: ' . $key, 1356478742);
129
+			}
130
+
131
+			$this->attributes[$key] = $attribute[$key];
132
+		}
133
+		return $this;
134
+	}
135
+
136
+	/**
137
+	 * @return string
138
+	 */
139
+	public function getTemplate()
140
+	{
141
+		return $this->template;
142
+	}
143
+
144
+	/**
145
+	 * @param string $template
146
+	 * @return \Fab\Media\Form\AbstractFormField
147
+	 */
148
+	public function setTemplate($template)
149
+	{
150
+		$this->template = $template;
151
+	}
152
+
153
+	/**
154
+	 * @return string
155
+	 */
156
+	public function getLabel()
157
+	{
158
+		return $this->label;
159
+	}
160
+
161
+	/**
162
+	 * @param string $label
163
+	 * @return \Fab\Media\Form\AbstractFormField
164
+	 */
165
+	public function setLabel($label)
166
+	{
167
+		$this->label = $label;
168
+		return $this;
169
+	}
170
+
171
+	/**
172
+	 * @return string
173
+	 */
174
+	public function getPrefix()
175
+	{
176
+		return $this->prefix;
177
+	}
178
+
179
+	/**
180
+	 * @param string $prefix
181
+	 * @return \Fab\Media\Form\AbstractFormField
182
+	 */
183
+	public function setPrefix($prefix)
184
+	{
185
+		$this->prefix = $prefix;
186
+		return $this;
187
+	}
188
+
189
+	/**
190
+	 * @return array
191
+	 */
192
+	public function getItems()
193
+	{
194
+		return $this->items;
195
+	}
196
+
197
+	/**
198
+	 * @param array $items
199
+	 */
200
+	public function setItems($items)
201
+	{
202
+		$this->items = $items;
203
+	}
204
+
205
+	/**
206
+	 * @return string
207
+	 */
208
+	public function getValue()
209
+	{
210
+		return htmlspecialchars($this->value);
211
+	}
212
+
213
+	/**
214
+	 * @param string $value
215
+	 * @return \Fab\Media\Form\AbstractFormField
216
+	 */
217
+	public function setValue($value)
218
+	{
219
+		$this->value = $value;
220
+		return $this;
221
+	}
222
+
223
+	/**
224
+	 * @return string
225
+	 */
226
+	public function getName()
227
+	{
228
+		$result = $this->name;
229
+		if ($this->getPrefix()) {
230
+			$result = sprintf('%s[%s]', $this->getPrefix(), $this->name);
231
+		}
232
+		return $result;
233
+	}
234
+
235
+	/**
236
+	 * @param string $name
237
+	 * @return \Fab\Media\Form\AbstractFormField
238
+	 */
239
+	public function setName($name)
240
+	{
241
+		$this->name = $name;
242
+		return $this;
243
+	}
244
+
245
+	/**
246
+	 * @return string
247
+	 */
248
+	public function getId()
249
+	{
250
+		if ($this->id === '') {
251
+			$this->id = DomElement::getInstance()->formatId($this->getName());
252
+		}
253
+		return $this->id;
254
+	}
255
+
256
+	/**
257
+	 * @param string $id
258
+	 * @return \Fab\Media\Form\AbstractFormField
259
+	 */
260
+	public function setId($id)
261
+	{
262
+		$this->id = $id;
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * @return array
268
+	 */
269
+	public function getAttributes()
270
+	{
271
+		return $this->attributes;
272
+	}
273
+
274
+	/**
275
+	 * @param array $attributes
276
+	 * @return \Fab\Media\Form\AbstractFormField
277
+	 */
278
+	public function setAttributes($attributes)
279
+	{
280
+		$this->attributes = $attributes;
281
+		return $this;
282
+	}
283 283
 
284 284
 }
Please login to merge, or discard this patch.
Classes/TypeConverter/FileConverter.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,43 +19,43 @@
 block discarded – undo
19 19
 class FileConverter extends AbstractTypeConverter
20 20
 {
21 21
 
22
-    /**
23
-     * @var array<string>
24
-     */
25
-    protected $sourceTypes = array('int');
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $targetType = 'TYPO3\CMS\Core\Resource\File';
31
-
32
-    /**
33
-     * @var integer
34
-     */
35
-    protected $priority = 1;
36
-
37
-    /**
38
-     * Actually convert from $source to $targetType
39
-     *
40
-     * @param string $source
41
-     * @param string $targetType
42
-     * @param array $convertedChildProperties
43
-     * @param PropertyMappingConfigurationInterface $configuration
44
-     * @return File
45
-     * @api
46
-     */
47
-    public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
48
-    {
49
-
50
-        /** @var $file File */
51
-        $file = ResourceFactory::getInstance()->getFileObject((int)$source);
52
-
53
-        if (!$file) {
54
-            $message = sprintf('File with identifier "%s" could not be found.', $file);
55
-            throw new \Exception($message, 1433529796);
56
-        }
57
-
58
-        $file->getType(); // force to internally know its mime-type.
59
-        return $file;
60
-    }
22
+	/**
23
+	 * @var array<string>
24
+	 */
25
+	protected $sourceTypes = array('int');
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $targetType = 'TYPO3\CMS\Core\Resource\File';
31
+
32
+	/**
33
+	 * @var integer
34
+	 */
35
+	protected $priority = 1;
36
+
37
+	/**
38
+	 * Actually convert from $source to $targetType
39
+	 *
40
+	 * @param string $source
41
+	 * @param string $targetType
42
+	 * @param array $convertedChildProperties
43
+	 * @param PropertyMappingConfigurationInterface $configuration
44
+	 * @return File
45
+	 * @api
46
+	 */
47
+	public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
48
+	{
49
+
50
+		/** @var $file File */
51
+		$file = ResourceFactory::getInstance()->getFileObject((int)$source);
52
+
53
+		if (!$file) {
54
+			$message = sprintf('File with identifier "%s" could not be found.', $file);
55
+			throw new \Exception($message, 1433529796);
56
+		}
57
+
58
+		$file->getType(); // force to internally know its mime-type.
59
+		return $file;
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
Classes/TypeConverter/ContentToFileConverter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -19,30 +19,30 @@
 block discarded – undo
19 19
 class ContentToFileConverter implements SingletonInterface
20 20
 {
21 21
 
22
-    /**
23
-     * Convert a file representation to File Resource.
24
-     *
25
-     * @param Content|int $fileRepresentation
26
-     * @throws \RuntimeException
27
-     * @return File
28
-     */
29
-    public function convert($fileRepresentation)
30
-    {
31
-
32
-        if ($fileRepresentation instanceof Content) {
33
-
34
-            $fileData = $fileRepresentation->toArray();
35
-            $fileData['modification_date'] = $fileData['tstamp'];
36
-
37
-            if (!isset($fileData['storage']) && $fileData['storage'] === null) {
38
-                throw new \RuntimeException('Storage identifier can not be null.', 1379946981);
39
-            }
40
-
41
-            $fileUid = $fileData['uid'];
42
-        } else {
43
-            $fileData = [];
44
-            $fileUid = (int)$fileRepresentation;
45
-        }
46
-        return ResourceFactory::getInstance()->getFileObject($fileUid, $fileData);
47
-    }
22
+	/**
23
+	 * Convert a file representation to File Resource.
24
+	 *
25
+	 * @param Content|int $fileRepresentation
26
+	 * @throws \RuntimeException
27
+	 * @return File
28
+	 */
29
+	public function convert($fileRepresentation)
30
+	{
31
+
32
+		if ($fileRepresentation instanceof Content) {
33
+
34
+			$fileData = $fileRepresentation->toArray();
35
+			$fileData['modification_date'] = $fileData['tstamp'];
36
+
37
+			if (!isset($fileData['storage']) && $fileData['storage'] === null) {
38
+				throw new \RuntimeException('Storage identifier can not be null.', 1379946981);
39
+			}
40
+
41
+			$fileUid = $fileData['uid'];
42
+		} else {
43
+			$fileData = [];
44
+			$fileUid = (int)$fileRepresentation;
45
+		}
46
+		return ResourceFactory::getInstance()->getFileObject($fileUid, $fileData);
47
+	}
48 48
 }
49 49
\ No newline at end of file
Please login to merge, or discard this patch.
Classes/ViewHelpers/ReportToViewHelper.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@
 block discarded – undo
16 16
 class ReportToViewHelper extends AbstractViewHelper
17 17
 {
18 18
 
19
-    /**
20
-     * Returns the people who will receive a report.
21
-     *
22
-     * @throws \Exception
23
-     * @return string
24
-     */
25
-    public function render()
26
-    {
27
-        $reportTo = 'null (Missing value in $GLOBALS[TYPO3_CONF_VARS][MAIL][defaultMailFromAddress])';
28
-        if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
29
-            $reportTo = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
30
-        }
31
-        return $reportTo;
32
-    }
19
+	/**
20
+	 * Returns the people who will receive a report.
21
+	 *
22
+	 * @throws \Exception
23
+	 * @return string
24
+	 */
25
+	public function render()
26
+	{
27
+		$reportTo = 'null (Missing value in $GLOBALS[TYPO3_CONF_VARS][MAIL][defaultMailFromAddress])';
28
+		if (!empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
29
+			$reportTo = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
30
+		}
31
+		return $reportTo;
32
+	}
33 33
 }
Please login to merge, or discard this patch.