forked from ezsystems/ezpublish-kernel
/
AuthorProcessor.php
51 lines (45 loc) · 1.56 KB
/
AuthorProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* File containing the AuthorProcessor class.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace eZ\Publish\Core\REST\Common\FieldTypeProcessor;
use eZ\Publish\Core\REST\Common\FieldTypeProcessor;
use eZ\Publish\Core\FieldType\Author\Type;
class AuthorProcessor extends FieldTypeProcessor
{
/**
* {@inheritdoc}
*/
public function preProcessFieldSettingsHash($incomingSettingsHash)
{
if (isset($incomingSettingsHash['defaultAuthor'])) {
switch ($incomingSettingsHash['defaultAuthor']) {
case 'DEFAULT_CURRENT_USER':
$incomingSettingsHash['defaultAuthor'] = Type::DEFAULT_CURRENT_USER;
break;
default:
$incomingSettingsHash['defaultAuthor'] = Type::DEFAULT_VALUE_EMPTY;
}
}
return $incomingSettingsHash;
}
/**
* {@inheritdoc}
*/
public function postProcessFieldSettingsHash($outgoingSettingsHash)
{
if (isset($outgoingSettingsHash['defaultAuthor'])) {
switch ($outgoingSettingsHash['defaultAuthor']) {
case Type::DEFAULT_CURRENT_USER:
$outgoingSettingsHash['defaultAuthor'] = 'DEFAULT_CURRENT_USER';
break;
default:
$outgoingSettingsHash['defaultAuthor'] = 'DEFAULT_VALUE_EMPTY';
}
}
return $outgoingSettingsHash;
}
}