You are here

class FBAutopostEntityEvent in Facebook Autopost 7

Special case for FacebookPublicationType Event

Hierarchy

Expanded class hierarchy of FBAutopostEntityEvent

File

fb_autopost_entity/class/FBAutopostEntityEvent.php, line 11
Class implementation for FBAutopostEntityEvent

View source
class FBAutopostEntityEvent extends FBAutopostEntity {

  /**
   * Prepares the parameters to publish to Facebook, this means settings any
   * field or destination dependent configuration.
   */
  protected function publishParameterPrepare(&$publication) {
    parent::publishParameterPrepare($publication);
    if (is_numeric($publication['params']['start_time'])) {
      $start = new DateTime('@' . $publication['params']['start_time']);
      $publication['params']['start_time'] = $start
        ->format(DateTime::ISO8601);
    }
    if (!empty($publication['params']['end_time']) && is_numeric($publication['params']['end_time'])) {
      $end = new DateTime('@' . $publication['params']['end_time']);
      $publication['params']['end_time'] = $end
        ->format(DateTime::ISO8601);
    }
  }

  /**
   * Edits a publication in facebook from a stored entity. Events in Facebook
   * can actually be updated, this means that there is no deletion needed.
   *
   * @param FacebookPublicationEntity $publication
   *   The fully loaded Facebook publication entity
   *
   * @throws FBAutopostException
   * @see FBAutopost::remoteEdit()
   */
  public function remoteEntityEdit(FacebookPublicationEntity $publication_entity) {

    // For an event we should update the Entity, instead of deleting an
    // recreating it.
    $wrapper = entity_metadata_wrapper('facebook_publication', $publication_entity);
    $remote_id = $wrapper->facebook_id
      ->value();
    $publication = array(
      'type' => $publication_entity->type,
      'params' => fb_autopost_entity_get_properties($publication_entity),
    );
    $this
      ->publishParameterPrepare($publication);

    // Call api method from ancestor.
    return $this
      ->api('/' . $remote_id, 'POST', $publication['params']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FBAutopost::$destination private property Destination for the publication. An string with the page ID or 'me'.
FBAutopost::$privacy public property Privacy setting for the publications. This property is made public because the getter method will give some formatting along with the property.
FBAutopost::$publication_types private property Publication types as defined in Facebook documentation Contains the name of the publication and the endpoint keyed by the machine name of the publication.
FBAutopost::$retry private property Boolean indicating wether to retry the publication or not when publishing on the user's timeline if the acting user does not have a valid access token.
FBAutopost::$type private property Stored publication type.
FBAutopost::checkPagesAvailability private function Throws an exception if the selected page id is not among the authorized ones.
FBAutopost::getDestination public function Gets the destination to publish to
FBAutopost::getEndpoint protected function Gets the endpoint of a publication
FBAutopost::getPagesAccessTokens private static function Get access tokens for publishing to several Facebook Pages
FBAutopost::getPagesData public function Gets the reply given from Facebook when asking for user account.
FBAutopost::getPrivacy public function Gets the privacy value.
FBAutopost::getRetry protected function Gets the publication type.
FBAutopost::getSession public function Gets the session object for sugar syntax. Factory method.
FBAutopost::getType protected function Gets the publication type.
FBAutopost::hasActiveAccessToken public function Checks if a user has an active access token.
FBAutopost::incorrect_param constant Constant indicating error code for an icorrect parameter
FBAutopost::missing_dependency constant Constant indicating error code for a missing dependency
FBAutopost::missing_param constant Constant indicating error code for a missing parameter
FBAutopost::publish function Publishes content in the selected pages
FBAutopost::publishOn protected function Publishes on a single destination.
FBAutopost::remoteDelete public function Deletes a publication from Facebook
FBAutopost::remoteEdit public function Edits a publication from Facebook
FBAutopost::sdk_error constant Constant indicating error code for a SDK thrown error
FBAutopost::setDestination public function Set the destination to publish to
FBAutopost::setPrivacy public function Sets the privacy.
FBAutopost::setRetry public function Sets the retry value.
FBAutopost::setType public function Sets the type value.
FBAutopost::__construct function
FBAutopostEntity::publishEntity public function Publishes content stored in a Facebook publication entity
FBAutopostEntity::remoteEntityDelete public function Deletes a publication from facebook stored in an entity.
FBAutopostEntityEvent::publishParameterPrepare protected function Prepares the parameters to publish to Facebook, this means settings any field or destination dependent configuration. Overrides FBAutopost::publishParameterPrepare
FBAutopostEntityEvent::remoteEntityEdit public function Edits a publication in facebook from a stored entity. Events in Facebook can actually be updated, this means that there is no deletion needed. Overrides FBAutopostEntity::remoteEntityEdit