public function createSubscription($principalUri, $uri, array $properties)
    {
        $fieldNames = [
            'principaluri',
            'uri',
            'source',
            'lastmodified',
        ];

        if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
            throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
        }

        $values = [
            ':principaluri' => $principalUri,
            ':uri' => $uri,
            ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(),
            ':lastmodified' => time(),
        ];

        foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
            if (isset($properties[$xmlName])) {
                $values[':'.$dbName] = $properties[$xmlName];
                $fieldNames[] = $dbName;
            }
        }

        $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarSubscriptionsTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')');
        $stmt->execute($values);

        return $this->pdo->lastInsertId(
            $this->calendarSubscriptionsTableName.'_id_seq'
        );
    }
public function createSubscription($principalUri, $uri, array $properties)
    {
        $fieldNames = [
            'principaluri',
            'uri',
            'source',
            'lastmodified',
        ];

        if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
            throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
        }

        $values = [
            ':principaluri' => $principalUri,
            ':uri' => $uri,
            ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(),
            ':lastmodified' => time(),
        ];

        foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
            if (isset($properties[$xmlName])) {
                $values[':'.$dbName] = $properties[$xmlName];
                $fieldNames[] = $dbName;
            }
        }

        $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarSubscriptionsTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')');
        $stmt->execute($values);

        return $this->pdo->lastInsertId(
            $this->calendarSubscriptionsTableName.'_id_seq'
        );
    }
public function createSubscription ( $ principalUri , $ uri , array $ properties ) { $ fieldNames = [ 'principaluri' , 'uri' , 'source' , 'lastmodified' , ] ; if ( ! isset ( $ properties [ '{http://calendarserver.org/ns/}source' ] ) ) { throw new Forbidden ( 'The {http://calendarserver.org/ns/}source property is required when creating subscriptions' ) ; } $ values = [ ':principaluri' => $ principalUri , ':uri' => $ uri , ':source' => $ properties [ '{http://calendarserver.org/ns/}source' ] -> getHref ( ) , ':lastmodified' => time ( ) , ] ; foreach ( $ this -> subscriptionPropertyMap as $ xmlName => $ dbName ) { if ( isset ( $ properties [ $ xmlName ] ) ) { $ values [ ':' . $ dbName ] = $ properties [ $ xmlName ] ; $ fieldNames [ ] = $ dbName ; } } $ stmt = $ this -> pdo -> prepare ( 'INSERT INTO ' . $ this -> calendarSubscriptionsTableName . ' (' . implode ( ', ' , $ fieldNames ) . ') VALUES (' . implode ( ', ' , array_keys ( $ values ) ) . ')' ) ; $ stmt -> execute ( $ values ) ; return $ this -> pdo -> lastInsertId ( $ this -> calendarSubscriptionsTableName . '_id_seq' ) ; }
Creates a new subscription for a principal.

If the creation was a success, an id must be returned that can be used to reference
this subscription in other methods, such as updateSubscription.

@param string $principalUri
@param string $uri
@param array  $properties

@return mixed
Creates a new subscription for a principal .