1<?php
2/**
3 * A decorator to represent a Kolab object attribute that can never be written.
4 *
5 * PHP version 5
6 *
7 * @category Kolab
8 * @package  Kolab_Server
9 * @author   Gunnar Wrobel <wrobel@pardus.de>
10 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
11 * @link     http://pear.horde.org/index.php?package=Kolab_Server
12 */
13
14/**
15 * A decorator to represent a Kolab object attribute that can never be written.
16 *
17 * Copyright 2008-2016 Horde LLC (http://www.horde.org/)
18 *
19 * See the enclosed file COPYING for license information (LGPL). If you
20 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21 *
22 * @category Kolab
23 * @package  Kolab_Server
24 * @author   Gunnar Wrobel <wrobel@pardus.de>
25 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
26 * @link     http://pear.horde.org/index.php?package=Kolab_Server
27 */
28class Horde_Kolab_Server_Object_Attribute_Writelock
29extends Horde_Kolab_Server_Object_Attribute_Decorator
30{
31    /**
32     * Return the new internal state for this attribute.
33     *
34     * @param array $changes The object data that should be updated.
35     *
36     * @return array The resulting internal state.
37     *
38     * @throws Horde_Kolab_Server_Exception If storing the value failed.
39     */
40    public function update(array $changes)
41    {
42        $changes = $this->_attribute->update($changes);
43        if (!empty($changes)) {
44            throw new Horde_Kolab_Server_Exception(
45                sprintf(
46                    "The value for \"%s\" may not be modified!",
47                    $this->_attribute->getExternalName()
48                )
49            );
50        }
51        return $changes;
52    }
53}