public function beforeSave(MetaModel $meta, $value, Model $model) { if ($value == 1) { // we need to publish this thing $stream = $meta->getOption('stream'); $publisherClass = "Ajde_Publisher_" . ucfirst($stream); /* @var $publisher Ajde_Publisher */ $publisher = new $publisherClass(); if (strtolower($stream) == 'twitter') { $publisher->setOptions(array('consumerKey' => $meta->getOption('twitter_consumerkey'), 'consumerSecret' => $meta->getOption('twitter_consumersecret'), 'token' => $meta->getOption('twitter_token'), 'tokenSecret' => $meta->getOption('twitter_tokensecret'))); } if (strtolower($stream) == 'mail') { $addresses = $model->getPublishRecipients(); $publisher->setRecipients($addresses); } // fill with content $publishData = $model->getPublishData(); $publisher->setTitle($publishData['title']); $publisher->setMessage($publishData['message']); $publisher->setImage($publishData['image']); $publisher->setUrl($publishData['url']); $value = $publisher->publish(); } return $value; }