public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch)
    {
        if (!is_array($calendarId)) {
            throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
        }
        list($calendarId, $instanceId) = $calendarId;

        $supportedProperties = array_keys($this->propertyMap);
        $supportedProperties[] = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp';

        $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId, $instanceId) {
            $newValues = [];
            foreach ($mutations as $propertyName => $propertyValue) {
                switch ($propertyName) {
                    case '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp':
                        $fieldName = 'transparent';
                        $newValues[$fieldName] = 'transparent' === $propertyValue->getValue();
                        break;
                    default:
                        $fieldName = $this->propertyMap[$propertyName];
                        $newValues[$fieldName] = $propertyValue;
                        break;
                }
            }
            $valuesSql = [];
            foreach ($newValues as $fieldName => $value) {
                $valuesSql[] = $fieldName.' = ?';
            }

            $stmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET '.implode(', ', $valuesSql).' WHERE id = ?');
            $newValues['id'] = $instanceId;
            $stmt->execute(array_values($newValues));

            $this->addChange($calendarId, '', 2);

            return true;
        });
    }
public function updateCalendar($calendarId, \Sabre\DAV\PropPatch $propPatch)
    {
        if (!is_array($calendarId)) {
            throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
        }
        list($calendarId, $instanceId) = $calendarId;

        $supportedProperties = array_keys($this->propertyMap);
        $supportedProperties[] = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp';

        $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId, $instanceId) {
            $newValues = [];
            foreach ($mutations as $propertyName => $propertyValue) {
                switch ($propertyName) {
                    case '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp':
                        $fieldName = 'transparent';
                        $newValues[$fieldName] = 'transparent' === $propertyValue->getValue();
                        break;
                    default:
                        $fieldName = $this->propertyMap[$propertyName];
                        $newValues[$fieldName] = $propertyValue;
                        break;
                }
            }
            $valuesSql = [];
            foreach ($newValues as $fieldName => $value) {
                $valuesSql[] = $fieldName.' = ?';
            }

            $stmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET '.implode(', ', $valuesSql).' WHERE id = ?');
            $newValues['id'] = $instanceId;
            $stmt->execute(array_values($newValues));

            $this->addChange($calendarId, '', 2);

            return true;
        });
    }
public function updateCalendar ( $ calendarId , \ Sabre \ DAV \ PropPatch $ propPatch ) { if ( ! is_array ( $ calendarId ) ) { throw new \ InvalidArgumentException ( 'The value passed to $calendarId is expected to be an array with a calendarId and an instanceId' ) ; } list ( $ calendarId , $ instanceId ) = $ calendarId ; $ supportedProperties = array_keys ( $ this -> propertyMap ) ; $ supportedProperties [ ] = '{' . CalDAV \ Plugin :: NS_CALDAV . '}schedule-calendar-transp' ; $ propPatch -> handle ( $ supportedProperties , function ( $ mutations ) use ( $ calendarId , $ instanceId ) { $ newValues = [ ] ; foreach ( $ mutations as $ propertyName => $ propertyValue ) { switch ( $ propertyName ) { case '{' . CalDAV \ Plugin :: NS_CALDAV . '}schedule-calendar-transp' : $ fieldName = 'transparent' ; $ newValues [ $ fieldName ] = 'transparent' === $ propertyValue -> getValue ( ) ; break ; default : $ fieldName = $ this -> propertyMap [ $ propertyName ] ; $ newValues [ $ fieldName ] = $ propertyValue ; break ; } } $ valuesSql = [ ] ; foreach ( $ newValues as $ fieldName => $ value ) { $ valuesSql [ ] = $ fieldName . ' = ?' ; } $ stmt = $ this -> pdo -> prepare ( 'UPDATE ' . $ this -> calendarInstancesTableName . ' SET ' . implode ( ', ' , $ valuesSql ) . ' WHERE id = ?' ) ; $ newValues [ 'id' ] = $ instanceId ; $ stmt -> execute ( array_values ( $ newValues ) ) ; $ this -> addChange ( $ calendarId , '' , 2 ) ; return true ; } ) ; }
Updates properties for a calendar.

The list of mutations is stored in a Sabre\DAV\PropPatch object.
To do the actual updates, you must tell this object which properties
you're going to process with the handle() method.

Calling the handle method is like telling the PropPatch object "I
promise I can handle updating this property".

Read the PropPatch documentation for more info and examples.

@param mixed                $calendarId
@param \Sabre\DAV\PropPatch $propPatch
Updates properties for a calendar .