/** * Convenience method for adding different contents * * @see parent */ protected function _defaultMethod($prefix, $camelized, $arguments) { switch ($prefix) { case 'add': case 'content': if (!in_array($camelized, self::$_supportedTypes)) { throw new InvalidArgumentException("Message object only supports " . implode(', ', self::$_supportedTypes) . " but provided {$camelized}."); } $object = $arguments[0]; if ($object instanceof Bronto_Object) { $object = $object->toArray(); } if (is_array($object)) { extract($object); } $object = array('type' => $camelized, 'subject' => empty($subject) ? $arguments[0] : $subject, 'content' => empty($content) ? $arguments[1] : $content); if (!array_key_exists('content', $this->_data)) { $this->_data['content'] = array(); } if (!array_key_exists($camelized, $this->_contentTypesToIndex)) { $this->_contentTypesToIndex[$camelized] = array_push($this->_data['content'], $object) - 1; } else { $this->_data['content'][$this->_contentTypesToIndex[$camelized]] = $object; } return $this; default: return parent::_defaultMethod($prefix, $camelized, $arguments); } }
/** * Allows an addtional prefix 'as' to set the type of field, ie: asText() * Also visibility, ie: asPublic(), asPrivate() * * @see parent */ protected function _defaultMethod($prefix, $camelized, $arguments) { switch ($prefix) { case 'as': if (array_key_exists($camelized, self::$_mappedWords)) { return $this->_set('visibility', self::$_mappedWords[$camelized]); } else { return $this->_set('type', $camelized); } case 'is': if (array_key_exists($camelized, self::$_mappedWords)) { return $this->_data['visibility'] == $camelized; } return $this->_data['type'] == $camelized; default: return parent::_defaultMethod($prefix, $camelized, $arguments); } }
/** * Allows chaining recipients together through function calls, ie: * $delivery->addContact($contactId)->ineligibleList($listId); * * @see parent */ protected function _defaultMethod($prefix, $camelized, $arguments) { switch ($prefix) { case 'add': case self::DELIVERY_SELECTED: case self::DELIVERY_ELIGIBLE: case self::DELIVERY_INELIGIBLE: $objectId = $arguments[0]; if ($objectId instanceof Bronto_Object) { $objectId = $objectId->getId(); } if (!array_key_exists('recipients', $this->_data)) { $this->_data['recipients'] = array(); } // TODO: we'll probably want to very here before sending // if the types set are valid or not $this->_data['recipients'][] = array('type' => $camelized, 'id' => $objectId, 'deliveryType' => $prefix == 'add' ? self::DELIVERY_SELECTED : $prefix); return $this; default: return parent::_defaultMethod($prefix, $camelized, $arguments); } }