Some community members expressed interest in using the SocialPost project without its tight Symfony coupling. With version 3 the project splits in two separate repositories. Because of this martin-georgiev/social-post-bundle
, which now contains only logic specific to the Symfony bundle, has a new dependency, martin-georgiev/social-post
. The latter one contains all the framework-agnostic logic for constructing and sending social network updates. Further to the repository split there are some namespace and class name changes:
- Namespace for
martin-georgiev/social-post-bundle
isMartinGeorgiev\SocialPostBundle
. This means when requiring the bundle inAppKernel.php
it has to be with the new FQNS.(MartinGeorgiev\SocialPostBundle\SocialBundle
) - Namespace for
martin-georgiev/social-post
isMartinGeorgiev\SocialPost
. This means when creating a new instance forMessage
it has to be imported from its new FQNS (MartinGeorgiev\SocialPost\Message
). - The enumeration class with social network names (previously
MartinGeorgiev\SocialPost\Provider\SocialNetwork
) is renamed toMartinGeorgiev\SocialPost\Provider\Enum
. - The publishing interface (previously
MartinGeorgiev\SocialPost\Provider\SocialNetworkPublisher
) is renamed toMartinGeorgiev\SocialPost\Publisher
.
- New class
MartinGeorgiev\SocialPost\Provider\Message
to represent any post to a social network. Its constructor takes the same arguments asSocialNetworkPublisher::publish()
was doing prior v2.0. This new class enables conditional publishing to a subset of the available networks. The default behaviour is to publish on all available networks. Example:
This message will be published on LinkedIn and Twitter, but not on Facebook
<?php
//...
$message = new \MartinGeorgiev\SocialPost\Provider\Message('your test message');
$message->setNetworksToPublishOn([SocialNetwork::LINKEDIN, SocialNetwork::TWITTER]);
$container->get('social_post')->publish($message);
SocialNetworkPublisher
interface (and publishing) changed. The long list of arguments onpublish()
was replaced with an instance ofMartinGeorgiev\SocialPost\Provider\Message
. See the example below:
Prior v2.0
<?php
//...
$container->get('social_post')->publish('your test message');
Since v2.0
<?php
//...
$message = new \MartinGeorgiev\SocialPost\Provider\Message('your test message');
$container->get('social_post')->publish($message);
- A new
FailureWhenPublishingMessage
exception replaced the now droppedFailureWhenPublishingSocialPost
. The new exception is still thrown for the same situations as the old one.