Completed
Push — master ( fb6736...59da86 )
by Fabien
03:11 queued 01:31
created
Classes/Utility/PermissionUtility.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -20,72 +20,72 @@
 block discarded – undo
20 20
 class PermissionUtility implements SingletonInterface
21 21
 {
22 22
 
23
-    /**
24
-     * Returns a class instance.
25
-     *
26
-     * @return PermissionUtility
27
-     * @throws \InvalidArgumentException
28
-     */
29
-    static public function getInstance()
30
-    {
31
-        return GeneralUtility::makeInstance(PermissionUtility::class);
32
-    }
23
+	/**
24
+	 * Returns a class instance.
25
+	 *
26
+	 * @return PermissionUtility
27
+	 * @throws \InvalidArgumentException
28
+	 */
29
+	static public function getInstance()
30
+	{
31
+		return GeneralUtility::makeInstance(PermissionUtility::class);
32
+	}
33 33
 
34
-    /**
35
-     * Returns allowed extensions given a possible storage.
36
-     *
37
-     * @param null|int|ResourceStorage $storage
38
-     * @return array
39
-     * @throws \InvalidArgumentException
40
-     */
41
-    public function getAllowedExtensions($storage = null)
42
-    {
34
+	/**
35
+	 * Returns allowed extensions given a possible storage.
36
+	 *
37
+	 * @param null|int|ResourceStorage $storage
38
+	 * @return array
39
+	 * @throws \InvalidArgumentException
40
+	 */
41
+	public function getAllowedExtensions($storage = null)
42
+	{
43 43
 
44
-        $fieldNames = array(
45
-            'extension_allowed_file_type_1',
46
-            'extension_allowed_file_type_2',
47
-            'extension_allowed_file_type_3',
48
-            'extension_allowed_file_type_4',
49
-            'extension_allowed_file_type_5',
50
-        );
44
+		$fieldNames = array(
45
+			'extension_allowed_file_type_1',
46
+			'extension_allowed_file_type_2',
47
+			'extension_allowed_file_type_3',
48
+			'extension_allowed_file_type_4',
49
+			'extension_allowed_file_type_5',
50
+		);
51 51
 
52
-        if (!is_null($storage)) {
53
-            if (!$storage instanceof ResourceStorage) {
54
-                $storage = ResourceFactory::getInstance()->getStorageObject((int)$storage);
55
-            }
56
-        } else {
57
-            $storage = $this->getMediaModule()->getCurrentStorage();
58
-        }
52
+		if (!is_null($storage)) {
53
+			if (!$storage instanceof ResourceStorage) {
54
+				$storage = ResourceFactory::getInstance()->getStorageObject((int)$storage);
55
+			}
56
+		} else {
57
+			$storage = $this->getMediaModule()->getCurrentStorage();
58
+		}
59 59
 
60
-        $storageRecord = $storage->getStorageRecord();
61
-        $allowedExtensions = [];
62
-        foreach ($fieldNames as $fieldName) {
63
-            $_allowedExtensions = GeneralUtility::trimExplode(',', $storageRecord[$fieldName], true);
64
-            $allowedExtensions = array_merge($allowedExtensions, $_allowedExtensions);
65
-        }
60
+		$storageRecord = $storage->getStorageRecord();
61
+		$allowedExtensions = [];
62
+		foreach ($fieldNames as $fieldName) {
63
+			$_allowedExtensions = GeneralUtility::trimExplode(',', $storageRecord[$fieldName], true);
64
+			$allowedExtensions = array_merge($allowedExtensions, $_allowedExtensions);
65
+		}
66 66
 
67
-        $uniqueAllowedExtensions = array_unique($allowedExtensions);
68
-        return array_filter($uniqueAllowedExtensions, 'strlen');
69
-    }
67
+		$uniqueAllowedExtensions = array_unique($allowedExtensions);
68
+		return array_filter($uniqueAllowedExtensions, 'strlen');
69
+	}
70 70
 
71
-    /**
72
-     * Returns allowed extensions list.
73
-     *
74
-     * @return string
75
-     * @throws \InvalidArgumentException
76
-     */
77
-    public function getAllowedExtensionList()
78
-    {
79
-        return implode(',', $this->getAllowedExtensions());
80
-    }
71
+	/**
72
+	 * Returns allowed extensions list.
73
+	 *
74
+	 * @return string
75
+	 * @throws \InvalidArgumentException
76
+	 */
77
+	public function getAllowedExtensionList()
78
+	{
79
+		return implode(',', $this->getAllowedExtensions());
80
+	}
81 81
 
82
-    /**
83
-     * @return MediaModule|object
84
-     * @throws \InvalidArgumentException
85
-     */
86
-    protected function getMediaModule()
87
-    {
88
-        return GeneralUtility::makeInstance(MediaModule::class);
89
-    }
82
+	/**
83
+	 * @return MediaModule|object
84
+	 * @throws \InvalidArgumentException
85
+	 */
86
+	protected function getMediaModule()
87
+	{
88
+		return GeneralUtility::makeInstance(MediaModule::class);
89
+	}
90 90
 
91 91
 }
Please login to merge, or discard this patch.
Classes/Utility/DomElement.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -16,57 +16,57 @@
 block discarded – undo
16 16
 class DomElement implements SingletonInterface
17 17
 {
18 18
 
19
-    /**
20
-     * Returns a class instance
21
-     *
22
-     * @return \Fab\Media\Utility\DomElement|object
23
-     */
24
-    static public function getInstance()
25
-    {
26
-        return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Media\Utility\DomElement::class);
27
-    }
19
+	/**
20
+	 * Returns a class instance
21
+	 *
22
+	 * @return \Fab\Media\Utility\DomElement|object
23
+	 */
24
+	static public function getInstance()
25
+	{
26
+		return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Fab\Media\Utility\DomElement::class);
27
+	}
28 28
 
29
-    /**
30
-     * Format an id given an input string
31
-     *
32
-     * @param string $input
33
-     * @return string
34
-     */
35
-    public function formatId($input)
36
-    {
29
+	/**
30
+	 * Format an id given an input string
31
+	 *
32
+	 * @param string $input
33
+	 * @return string
34
+	 */
35
+	public function formatId($input)
36
+	{
37 37
 
38
-        // remove the capital letter from the id
39
-        $segments = preg_split('/(?=[A-Z])/', $input);
40
-        $segments = array_map('strtolower', $segments);
41
-        if ($segments[0] == '') {
42
-            array_shift($segments);
43
-        }
44
-        $result = implode('-', $segments);
38
+		// remove the capital letter from the id
39
+		$segments = preg_split('/(?=[A-Z])/', $input);
40
+		$segments = array_map('strtolower', $segments);
41
+		if ($segments[0] == '') {
42
+			array_shift($segments);
43
+		}
44
+		$result = implode('-', $segments);
45 45
 
46
-        return $this->sanitizeId($result);
47
-    }
46
+		return $this->sanitizeId($result);
47
+	}
48 48
 
49
-    /**
50
-     * Sanitize an id
51
-     *
52
-     * @param string $input
53
-     * @return mixed
54
-     */
55
-    protected function sanitizeId($input)
56
-    {
49
+	/**
50
+	 * Sanitize an id
51
+	 *
52
+	 * @param string $input
53
+	 * @return mixed
54
+	 */
55
+	protected function sanitizeId($input)
56
+	{
57 57
 
58
-        // remove the track of possible namespace
59
-        $searches[] = ' ';
60
-        $searches[] = '_';
61
-        $searches[] = '--';
62
-        $searches[] = '[';
63
-        $searches[] = ']';
64
-        $replaces[] = '-';
65
-        $replaces[] = '-';
66
-        $replaces[] = '-';
67
-        $replaces[] = '-';
68
-        $replaces[] = '';
69
-        return str_replace($searches, $replaces, strtolower($input));
70
-    }
58
+		// remove the track of possible namespace
59
+		$searches[] = ' ';
60
+		$searches[] = '_';
61
+		$searches[] = '--';
62
+		$searches[] = '[';
63
+		$searches[] = ']';
64
+		$replaces[] = '-';
65
+		$replaces[] = '-';
66
+		$replaces[] = '-';
67
+		$replaces[] = '-';
68
+		$replaces[] = '';
69
+		return str_replace($searches, $replaces, strtolower($input));
70
+	}
71 71
 
72 72
 }
Please login to merge, or discard this patch.
Classes/Utility/ImagePresetUtility.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -16,92 +16,92 @@
 block discarded – undo
16 16
 class ImagePresetUtility implements \TYPO3\CMS\Core\SingletonInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    protected $store = [];
19
+	/**
20
+	 * @var array
21
+	 */
22
+	protected $store = [];
23 23
 
24
-    /**
25
-     * @var string
26
-     */
27
-    protected $currentPreset = '';
24
+	/**
25
+	 * @var string
26
+	 */
27
+	protected $currentPreset = '';
28 28
 
29
-    /**
30
-     * Returns a class instance
31
-     *
32
-     * @return \Fab\Media\Utility\ImagePresetUtility|object
33
-     */
34
-    static public function getInstance()
35
-    {
36
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class);
37
-    }
29
+	/**
30
+	 * Returns a class instance
31
+	 *
32
+	 * @return \Fab\Media\Utility\ImagePresetUtility|object
33
+	 */
34
+	static public function getInstance()
35
+	{
36
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\ImagePresetUtility::class);
37
+	}
38 38
 
39
-    /**
40
-     * Set the current preset value. Preset values come from the settings and can be:
41
-     * image_thumbnail, image_mini, image_small, image_medium, image_large
42
-     *
43
-     * @throws \Fab\Media\Exception\EmptyValueException
44
-     * @param string $preset image_thumbnail, image_mini, ...
45
-     * @return \Fab\Media\Utility\ImagePresetUtility
46
-     */
47
-    public function preset($preset)
48
-    {
49
-        $size = ConfigurationUtility::getInstance()->get($preset);
50
-        if (is_null($size)) {
51
-            throw new \Fab\Media\Exception\EmptyValueException('No value for preset: ' . $preset, 1362501066);
52
-        }
39
+	/**
40
+	 * Set the current preset value. Preset values come from the settings and can be:
41
+	 * image_thumbnail, image_mini, image_small, image_medium, image_large
42
+	 *
43
+	 * @throws \Fab\Media\Exception\EmptyValueException
44
+	 * @param string $preset image_thumbnail, image_mini, ...
45
+	 * @return \Fab\Media\Utility\ImagePresetUtility
46
+	 */
47
+	public function preset($preset)
48
+	{
49
+		$size = ConfigurationUtility::getInstance()->get($preset);
50
+		if (is_null($size)) {
51
+			throw new \Fab\Media\Exception\EmptyValueException('No value for preset: ' . $preset, 1362501066);
52
+		}
53 53
 
54
-        $this->currentPreset = $preset;
55
-        if (!isset($this->store[$this->currentPreset])) {
56
-            // @todo use object Dimension instead
57
-            $dimensions = GeneralUtility::trimExplode('x', $size);
58
-            $this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
59
-            $this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
60
-        }
61
-        return $this;
62
-    }
54
+		$this->currentPreset = $preset;
55
+		if (!isset($this->store[$this->currentPreset])) {
56
+			// @todo use object Dimension instead
57
+			$dimensions = GeneralUtility::trimExplode('x', $size);
58
+			$this->store[$this->currentPreset]['width'] = empty($dimensions[0]) ? 0 : $dimensions[0];
59
+			$this->store[$this->currentPreset]['height'] = empty($dimensions[1]) ? 0 : $dimensions[1];
60
+		}
61
+		return $this;
62
+	}
63 63
 
64
-    /**
65
-     * @return array
66
-     */
67
-    public function getStore()
68
-    {
69
-        return $this->store;
70
-    }
64
+	/**
65
+	 * @return array
66
+	 */
67
+	public function getStore()
68
+	{
69
+		return $this->store;
70
+	}
71 71
 
72
-    /**
73
-     * @param array $store
74
-     */
75
-    public function setStore($store)
76
-    {
77
-        $this->store = $store;
78
-    }
72
+	/**
73
+	 * @param array $store
74
+	 */
75
+	public function setStore($store)
76
+	{
77
+		$this->store = $store;
78
+	}
79 79
 
80
-    /**
81
-     * Returns width of the current preset.
82
-     *
83
-     * @throws \Fab\Media\Exception\InvalidKeyInArrayException
84
-     * @return int
85
-     */
86
-    public function getWidth()
87
-    {
88
-        if (empty($this->store[$this->currentPreset])) {
89
-            throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
90
-        }
91
-        return (int)$this->store[$this->currentPreset]['width'];
92
-    }
80
+	/**
81
+	 * Returns width of the current preset.
82
+	 *
83
+	 * @throws \Fab\Media\Exception\InvalidKeyInArrayException
84
+	 * @return int
85
+	 */
86
+	public function getWidth()
87
+	{
88
+		if (empty($this->store[$this->currentPreset])) {
89
+			throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
90
+		}
91
+		return (int)$this->store[$this->currentPreset]['width'];
92
+	}
93 93
 
94
-    /**
95
-     * Returns height of the current preset.
96
-     *
97
-     * @throws \Fab\Media\Exception\InvalidKeyInArrayException
98
-     * @return int
99
-     */
100
-    public function getHeight()
101
-    {
102
-        if (empty($this->store[$this->currentPreset])) {
103
-            throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
104
-        }
105
-        return (int)$this->store[$this->currentPreset]['height'];
106
-    }
94
+	/**
95
+	 * Returns height of the current preset.
96
+	 *
97
+	 * @throws \Fab\Media\Exception\InvalidKeyInArrayException
98
+	 * @return int
99
+	 */
100
+	public function getHeight()
101
+	{
102
+		if (empty($this->store[$this->currentPreset])) {
103
+			throw new \Fab\Media\Exception\InvalidKeyInArrayException('No existing values for current preset. Have you set a preset?', 1362501853);
104
+		}
105
+		return (int)$this->store[$this->currentPreset]['height'];
106
+	}
107 107
 }
Please login to merge, or discard this patch.
Classes/Utility/ConfigurationUtility.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -18,75 +18,75 @@
 block discarded – undo
18 18
 class ConfigurationUtility implements \TYPO3\CMS\Core\SingletonInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    protected $extensionKey = 'media';
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected $extensionKey = 'media';
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    protected $configuration = [];
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $configuration = [];
30 30
 
31
-    /**
32
-     * Returns a class instance.
33
-     *
34
-     * @return \Fab\Media\Utility\ConfigurationUtility|object
35
-     */
36
-    static public function getInstance()
37
-    {
38
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class);
39
-    }
31
+	/**
32
+	 * Returns a class instance.
33
+	 *
34
+	 * @return \Fab\Media\Utility\ConfigurationUtility|object
35
+	 */
36
+	static public function getInstance()
37
+	{
38
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\ConfigurationUtility::class);
39
+	}
40 40
 
41
-    /**
42
-     * Constructor
43
-     */
44
-    public function __construct()
45
-    {
46
-        $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media');
41
+	/**
42
+	 * Constructor
43
+	 */
44
+	public function __construct()
45
+	{
46
+		$configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('media');
47 47
 
48
-        // Fill up configuration array with relevant values.
49
-        foreach ($configuration as $key => $value) {
50
-            $this->configuration[$key] = $value;
51
-        }
52
-    }
48
+		// Fill up configuration array with relevant values.
49
+		foreach ($configuration as $key => $value) {
50
+			$this->configuration[$key] = $value;
51
+		}
52
+	}
53 53
 
54
-    /**
55
-     * @return ObjectManager|object
56
-     */
57
-    protected function getObjectManager()
58
-    {
59
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
60
-    }
54
+	/**
55
+	 * @return ObjectManager|object
56
+	 */
57
+	protected function getObjectManager()
58
+	{
59
+		return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
60
+	}
61 61
 
62
-    /**
63
-     * Returns a setting key.
64
-     *
65
-     * @param string $key
66
-     * @return array
67
-     */
68
-    public function get($key)
69
-    {
70
-        return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null;
71
-    }
62
+	/**
63
+	 * Returns a setting key.
64
+	 *
65
+	 * @param string $key
66
+	 * @return array
67
+	 */
68
+	public function get($key)
69
+	{
70
+		return isset($this->configuration[$key]) ? trim($this->configuration[$key]) : null;
71
+	}
72 72
 
73
-    /**
74
-     * Set a setting key.
75
-     *
76
-     * @param string $key
77
-     * @param mixed $value
78
-     * @return void
79
-     */
80
-    public function set($key, $value)
81
-    {
82
-        $this->configuration[$key] = $value;
83
-    }
73
+	/**
74
+	 * Set a setting key.
75
+	 *
76
+	 * @param string $key
77
+	 * @param mixed $value
78
+	 * @return void
79
+	 */
80
+	public function set($key, $value)
81
+	{
82
+		$this->configuration[$key] = $value;
83
+	}
84 84
 
85
-    /**
86
-     * @return array
87
-     */
88
-    public function getConfiguration()
89
-    {
90
-        return $this->configuration;
91
-    }
85
+	/**
86
+	 * @return array
87
+	 */
88
+	public function getConfiguration()
89
+	{
90
+		return $this->configuration;
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Classes/Utility/SessionUtility.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@
 block discarded – undo
16 16
 class SessionUtility implements \TYPO3\CMS\Core\SingletonInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $moduleKey = 'media';
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $moduleKey = 'media';
23 23
 
24
-    /**
25
-     * Returns a class instance.
26
-     *
27
-     * @return \Fab\Media\Utility\SessionUtility|object
28
-     */
29
-    static public function getInstance()
30
-    {
31
-        return GeneralUtility::makeInstance(\Fab\Media\Utility\SessionUtility::class);
32
-    }
24
+	/**
25
+	 * Returns a class instance.
26
+	 *
27
+	 * @return \Fab\Media\Utility\SessionUtility|object
28
+	 */
29
+	static public function getInstance()
30
+	{
31
+		return GeneralUtility::makeInstance(\Fab\Media\Utility\SessionUtility::class);
32
+	}
33 33
 
34
-    public function __construct()
35
-    {
34
+	public function __construct()
35
+	{
36 36
 
37
-        // Initialize storage from the current
38
-        if (!is_array($this->getBackendUser()->uc['moduleData'][$this->moduleKey])) {
39
-            $this->getBackendUser()->uc['moduleData'][$this->moduleKey] = [];
40
-            $this->getBackendUser()->writeUC();
41
-        }
42
-    }
37
+		// Initialize storage from the current
38
+		if (!is_array($this->getBackendUser()->uc['moduleData'][$this->moduleKey])) {
39
+			$this->getBackendUser()->uc['moduleData'][$this->moduleKey] = [];
40
+			$this->getBackendUser()->writeUC();
41
+		}
42
+	}
43 43
 
44
-    /**
45
-     * Return a value from the Session according to the key
46
-     *
47
-     * @param string $key
48
-     * @return mixed
49
-     */
50
-    public function get($key)
51
-    {
52
-        return $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key];
53
-    }
44
+	/**
45
+	 * Return a value from the Session according to the key
46
+	 *
47
+	 * @param string $key
48
+	 * @return mixed
49
+	 */
50
+	public function get($key)
51
+	{
52
+		return $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key];
53
+	}
54 54
 
55
-    /**
56
-     * Set a key to the Session.
57
-     *
58
-     * @param string $key
59
-     * @param mixed $value
60
-     * @return void
61
-     */
62
-    public function set($key, $value)
63
-    {
64
-        $this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key] = $value;
65
-        $this->getBackendUser()->writeUC();
66
-    }
55
+	/**
56
+	 * Set a key to the Session.
57
+	 *
58
+	 * @param string $key
59
+	 * @param mixed $value
60
+	 * @return void
61
+	 */
62
+	public function set($key, $value)
63
+	{
64
+		$this->getBackendUser()->uc['moduleData'][$this->moduleKey][$key] = $value;
65
+		$this->getBackendUser()->writeUC();
66
+	}
67 67
 
68
-    /**
69
-     * Returns an instance of the current Backend User.
70
-     *
71
-     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
72
-     */
73
-    protected function getBackendUser()
74
-    {
75
-        return $GLOBALS['BE_USER'];
76
-    }
68
+	/**
69
+	 * Returns an instance of the current Backend User.
70
+	 *
71
+	 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
72
+	 */
73
+	protected function getBackendUser()
74
+	{
75
+		return $GLOBALS['BE_USER'];
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Classes/DataHandler/FileDataHandler.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -21,127 +21,127 @@
 block discarded – undo
21 21
 class FileDataHandler extends AbstractDataHandler
22 22
 {
23 23
 
24
-    /**
25
-     * Process File with action "update".
26
-     *
27
-     * @param Content $content
28
-     * @throws \Exception
29
-     * @return bool
30
-     */
31
-    public function processUpdate(Content $content)
32
-    {
33
-        throw new \Exception('Not yet implemented', 1409988673);
34
-    }
35
-
36
-    /**
37
-     * Process File with action "remove".
38
-     *
39
-     * @param Content $content
40
-     * @return bool|void
41
-     */
42
-    public function processRemove(Content $content)
43
-    {
44
-        $file = ResourceFactory::getInstance()->getFileObject($content->getUid());
45
-
46
-        $numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
47
-        if ($numberOfReferences === 0) {
48
-            $file->delete();
49
-        } else {
50
-            $message = sprintf('I could not delete file "%s" as it is has %s reference(s).', $file->getUid(), $numberOfReferences);
51
-            $this->errorMessages = $message;
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Process File with action "copy".
57
-     *
58
-     * @param Content $content
59
-     * @param string $target
60
-     * @throws \Exception
61
-     * @return bool
62
-     */
63
-    public function processCopy(Content $content, $target)
64
-    {
65
-        $file = ResourceFactory::getInstance()->getFileObject($content->getUid());
66
-
67
-        if ($this->getMediaModule()->hasFolderTree()) {
68
-
69
-            $targetFolder = $this->getMediaModule()->getCurrentFolder();
70
-
71
-            // Move file
72
-            $file->copyTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
73
-        }
74
-        return true;
75
-    }
76
-
77
-    /**
78
-     * Process File with action "move".
79
-     *
80
-     * @param Content $content
81
-     * @param string $target
82
-     * @throws \Exception
83
-     * @return bool
84
-     */
85
-    public function processMove(Content $content, $target)
86
-    {
87
-        $file = ResourceFactory::getInstance()->getFileObject($content->getUid());
88
-
89
-        if ($this->getMediaModule()->hasFolderTree()) {
90
-
91
-            $targetFolder = $this->getMediaModule()->getCurrentFolder();
92
-            if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) {
93
-
94
-                // Move file
95
-                $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
96
-            }
97
-        } else {
98
-
99
-            // Only process if the storage is different.
100
-            if ((int)$file->getStorage()->getUid() !== (int)$target) {
101
-
102
-                $targetStorage = ResourceFactory::getInstance()->getStorageObject((int)$target);
103
-
104
-                // Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission.
105
-                $targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file);
106
-
107
-                try {
108
-                    // Move file
109
-                    $file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
110
-                } catch (\Exception $e) {
111
-                    $this->errorMessages = $e->getMessage();
112
-                }
113
-            }
114
-        }
115
-        return true;
116
-    }
117
-
118
-    /**
119
-     * @return \Fab\Media\Resource\FileReferenceService|object
120
-     */
121
-    protected function getFileReferenceService()
122
-    {
123
-        return GeneralUtility::makeInstance(\Fab\Media\Resource\FileReferenceService::class);
124
-    }
125
-
126
-    /**
127
-     * Process Content with action "localize".
128
-     *
129
-     * @param Content $content
130
-     * @param int $language
131
-     * @throws \Exception
132
-     * @return bool
133
-     */
134
-    public function processLocalize(Content $content, $language)
135
-    {
136
-        throw new \Exception('Nothing to implement here. Localization is done by the Core DataHandler', 1412760788);
137
-    }
138
-
139
-    /**
140
-     * @return MediaModule|object
141
-     */
142
-    protected function getMediaModule()
143
-    {
144
-        return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
145
-    }
24
+	/**
25
+	 * Process File with action "update".
26
+	 *
27
+	 * @param Content $content
28
+	 * @throws \Exception
29
+	 * @return bool
30
+	 */
31
+	public function processUpdate(Content $content)
32
+	{
33
+		throw new \Exception('Not yet implemented', 1409988673);
34
+	}
35
+
36
+	/**
37
+	 * Process File with action "remove".
38
+	 *
39
+	 * @param Content $content
40
+	 * @return bool|void
41
+	 */
42
+	public function processRemove(Content $content)
43
+	{
44
+		$file = ResourceFactory::getInstance()->getFileObject($content->getUid());
45
+
46
+		$numberOfReferences = $this->getFileReferenceService()->countTotalReferences($file);
47
+		if ($numberOfReferences === 0) {
48
+			$file->delete();
49
+		} else {
50
+			$message = sprintf('I could not delete file "%s" as it is has %s reference(s).', $file->getUid(), $numberOfReferences);
51
+			$this->errorMessages = $message;
52
+		}
53
+	}
54
+
55
+	/**
56
+	 * Process File with action "copy".
57
+	 *
58
+	 * @param Content $content
59
+	 * @param string $target
60
+	 * @throws \Exception
61
+	 * @return bool
62
+	 */
63
+	public function processCopy(Content $content, $target)
64
+	{
65
+		$file = ResourceFactory::getInstance()->getFileObject($content->getUid());
66
+
67
+		if ($this->getMediaModule()->hasFolderTree()) {
68
+
69
+			$targetFolder = $this->getMediaModule()->getCurrentFolder();
70
+
71
+			// Move file
72
+			$file->copyTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
73
+		}
74
+		return true;
75
+	}
76
+
77
+	/**
78
+	 * Process File with action "move".
79
+	 *
80
+	 * @param Content $content
81
+	 * @param string $target
82
+	 * @throws \Exception
83
+	 * @return bool
84
+	 */
85
+	public function processMove(Content $content, $target)
86
+	{
87
+		$file = ResourceFactory::getInstance()->getFileObject($content->getUid());
88
+
89
+		if ($this->getMediaModule()->hasFolderTree()) {
90
+
91
+			$targetFolder = $this->getMediaModule()->getCurrentFolder();
92
+			if ($targetFolder->getIdentifier() !== $file->getParentFolder()->getIdentifier()) {
93
+
94
+				// Move file
95
+				$file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
96
+			}
97
+		} else {
98
+
99
+			// Only process if the storage is different.
100
+			if ((int)$file->getStorage()->getUid() !== (int)$target) {
101
+
102
+				$targetStorage = ResourceFactory::getInstance()->getStorageObject((int)$target);
103
+
104
+				// Retrieve target directory in the new storage. The folder will only be returned if the User has the correct permission.
105
+				$targetFolder = $this->getMediaModule()->getDefaultFolderInStorage($targetStorage, $file);
106
+
107
+				try {
108
+					// Move file
109
+					$file->moveTo($targetFolder, $file->getName(), DuplicationBehavior::RENAME);
110
+				} catch (\Exception $e) {
111
+					$this->errorMessages = $e->getMessage();
112
+				}
113
+			}
114
+		}
115
+		return true;
116
+	}
117
+
118
+	/**
119
+	 * @return \Fab\Media\Resource\FileReferenceService|object
120
+	 */
121
+	protected function getFileReferenceService()
122
+	{
123
+		return GeneralUtility::makeInstance(\Fab\Media\Resource\FileReferenceService::class);
124
+	}
125
+
126
+	/**
127
+	 * Process Content with action "localize".
128
+	 *
129
+	 * @param Content $content
130
+	 * @param int $language
131
+	 * @throws \Exception
132
+	 * @return bool
133
+	 */
134
+	public function processLocalize(Content $content, $language)
135
+	{
136
+		throw new \Exception('Nothing to implement here. Localization is done by the Core DataHandler', 1412760788);
137
+	}
138
+
139
+	/**
140
+	 * @return MediaModule|object
141
+	 */
142
+	protected function getMediaModule()
143
+	{
144
+		return GeneralUtility::makeInstance(\Fab\Media\Module\MediaModule::class);
145
+	}
146 146
 
147 147
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/File/ExistsViewHelper.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -19,36 +19,36 @@
 block discarded – undo
19 19
 class ExistsViewHelper extends AbstractViewHelper
20 20
 {
21 21
 
22
-    /**
23
-     * @return void
24
-     */
25
-    public function initializeArguments()
26
-    {
27
-        $this->registerArgument('file', 'mixed', '', true);
28
-    }
29
-
30
-    /**
31
-     * Returns a property value of a file given by the context.
32
-     *
33
-     * @return bool
34
-     */
35
-    public function render()
36
-    {
37
-        /** @var File|Content|int $file $file */
38
-        $file = $this->arguments['file'];
39
-
40
-        if (!$file instanceof File) {
41
-            $file = $this->getFileConverter()->convert($file);
42
-        }
43
-
44
-        return $file->exists();
45
-    }
46
-
47
-    /**
48
-     * @return \Fab\Media\TypeConverter\ContentToFileConverter|object
49
-     */
50
-    protected function getFileConverter()
51
-    {
52
-        return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class);
53
-    }
22
+	/**
23
+	 * @return void
24
+	 */
25
+	public function initializeArguments()
26
+	{
27
+		$this->registerArgument('file', 'mixed', '', true);
28
+	}
29
+
30
+	/**
31
+	 * Returns a property value of a file given by the context.
32
+	 *
33
+	 * @return bool
34
+	 */
35
+	public function render()
36
+	{
37
+		/** @var File|Content|int $file $file */
38
+		$file = $this->arguments['file'];
39
+
40
+		if (!$file instanceof File) {
41
+			$file = $this->getFileConverter()->convert($file);
42
+		}
43
+
44
+		return $file->exists();
45
+	}
46
+
47
+	/**
48
+	 * @return \Fab\Media\TypeConverter\ContentToFileConverter|object
49
+	 */
50
+	protected function getFileConverter()
51
+	{
52
+		return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class);
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/File/PropertyViewHelper.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@
 block discarded – undo
17 17
 class PropertyViewHelper extends AbstractViewHelper
18 18
 {
19 19
 
20
-    /**
21
-     * @return void
22
-     */
23
-    public function initializeArguments()
24
-    {
25
-        $this->registerArgument('name', 'string', '', true);
26
-    }
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function initializeArguments()
24
+	{
25
+		$this->registerArgument('name', 'string', '', true);
26
+	}
27 27
 
28
-    /**
29
-     * Returns a property value of a file given by the context.
30
-     *
31
-     * @return string
32
-     */
33
-    public function render()
34
-    {
35
-        $name = $this->arguments['name'];
28
+	/**
29
+	 * Returns a property value of a file given by the context.
30
+	 *
31
+	 * @return string
32
+	 */
33
+	public function render()
34
+	{
35
+		$name = $this->arguments['name'];
36 36
 
37
-        /** @var File $file */
38
-        $file = $this->templateVariableContainer->get('file');
39
-        return $file->getProperty($name);
40
-    }
37
+		/** @var File $file */
38
+		$file = $this->templateVariableContainer->get('file');
39
+		return $file->getProperty($name);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Classes/ViewHelpers/File/ThumbnailViewHelper.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -21,65 +21,65 @@
 block discarded – undo
21 21
 class ThumbnailViewHelper extends AbstractViewHelper
22 22
 {
23 23
 
24
-    /**
25
-     * @return void
26
-     */
27
-    public function initializeArguments()
28
-    {
29
-        $this->registerArgument('file', 'mixed', 'The source file', false, null);
30
-        $this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []);
31
-        $this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, '');
32
-        $this->registerArgument('preset', 'string', 'Image dimension preset', false, '');
33
-        $this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image');
34
-        $this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, '');
35
-    }
24
+	/**
25
+	 * @return void
26
+	 */
27
+	public function initializeArguments()
28
+	{
29
+		$this->registerArgument('file', 'mixed', 'The source file', false, null);
30
+		$this->registerArgument('configuration', 'array', 'Configuration to be given for the thumbnail processing.', false, []);
31
+		$this->registerArgument('attributes', 'array', 'DOM attributes to add to the thumbnail image', false, '');
32
+		$this->registerArgument('preset', 'string', 'Image dimension preset', false, '');
33
+		$this->registerArgument('output', 'string', 'Can be: uri, image, imageWrapped', false, 'image');
34
+		$this->registerArgument('configurationWrap', 'array', 'The configuration given to the wrap.', false, '');
35
+	}
36 36
 
37
-    /**
38
-     * Returns a configurable thumbnail of an asset
39
-     *
40
-     * @throws \Exception
41
-     * @return string
42
-     */
43
-    public function render()
44
-    {
37
+	/**
38
+	 * Returns a configurable thumbnail of an asset
39
+	 *
40
+	 * @throws \Exception
41
+	 * @return string
42
+	 */
43
+	public function render()
44
+	{
45 45
 
46
-        $file = $this->arguments['file'];
47
-        $preset = $this->arguments['preset'];
48
-        $configuration = $this->arguments['configuration'];
49
-        if (!is_array($configuration)) {
50
-            $configuration = array();
51
-        }
52
-        $configurationWrap = $this->arguments['configurationWrap'];
53
-        $attributes = $this->arguments['attributes'];
54
-        $output = $this->arguments['output'];
46
+		$file = $this->arguments['file'];
47
+		$preset = $this->arguments['preset'];
48
+		$configuration = $this->arguments['configuration'];
49
+		if (!is_array($configuration)) {
50
+			$configuration = array();
51
+		}
52
+		$configurationWrap = $this->arguments['configurationWrap'];
53
+		$attributes = $this->arguments['attributes'];
54
+		$output = $this->arguments['output'];
55 55
 
56
-        if ($file instanceof Content) {
57
-            $file = $this->getFileConverter()->convert($file);
58
-        } elseif (!($file instanceof File)) {
59
-            $file = ResourceFactory::getInstance()->getFileObject((int)$file);
60
-        }
61
-        if ($preset) {
62
-            $imageDimension = ImagePresetUtility::getInstance()->preset($preset);
63
-            $configuration['width'] = $imageDimension->getWidth();
64
-            $configuration['height'] = $imageDimension->getHeight();
65
-        }
66
-        /** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
67
-        $thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $file);
68
-        $thumbnail = $thumbnailService->setConfiguration($configuration)
69
-            ->setConfigurationWrap($configurationWrap)
70
-            ->setAttributes($attributes)
71
-            ->setOutputType($output)
72
-            ->create();
56
+		if ($file instanceof Content) {
57
+			$file = $this->getFileConverter()->convert($file);
58
+		} elseif (!($file instanceof File)) {
59
+			$file = ResourceFactory::getInstance()->getFileObject((int)$file);
60
+		}
61
+		if ($preset) {
62
+			$imageDimension = ImagePresetUtility::getInstance()->preset($preset);
63
+			$configuration['width'] = $imageDimension->getWidth();
64
+			$configuration['height'] = $imageDimension->getHeight();
65
+		}
66
+		/** @var $thumbnailService \Fab\Media\Thumbnail\ThumbnailService */
67
+		$thumbnailService = GeneralUtility::makeInstance(\Fab\Media\Thumbnail\ThumbnailService::class, $file);
68
+		$thumbnail = $thumbnailService->setConfiguration($configuration)
69
+			->setConfigurationWrap($configurationWrap)
70
+			->setAttributes($attributes)
71
+			->setOutputType($output)
72
+			->create();
73 73
 
74
-        return $thumbnail;
75
-    }
74
+		return $thumbnail;
75
+	}
76 76
 
77
-    /**
78
-     * @return \Fab\Media\TypeConverter\ContentToFileConverter|object
79
-     */
80
-    protected function getFileConverter()
81
-    {
82
-        return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class);
83
-    }
77
+	/**
78
+	 * @return \Fab\Media\TypeConverter\ContentToFileConverter|object
79
+	 */
80
+	protected function getFileConverter()
81
+	{
82
+		return GeneralUtility::makeInstance(\Fab\Media\TypeConverter\ContentToFileConverter::class);
83
+	}
84 84
 
85 85
 }
Please login to merge, or discard this patch.