function fb_instant_articles_api_rules_remove_article in Facebook Instant Articles 7.2
Same name and namespace in other branches
- 7 modules/fb_instant_articles_api_rules/fb_instant_articles_api_rules.module \fb_instant_articles_api_rules_remove_article()
Implementation of a Facebook instant article remove.
Parameters
object $node:
2 calls to fb_instant_articles_api_rules_remove_article()
- facebook_instant_articles_api_remove_action in modules/
fb_instant_articles_api_rules/ fb_instant_articles_api_rules.module - Implementation of a Facebook instant article node delete action.
- fb_instant_articles_api_rules_action_remove in modules/
fb_instant_articles_api_rules/ fb_instant_articles_api_rules.rules.inc - Action: Delete facebook instant article.
File
- modules/
fb_instant_articles_api_rules/ fb_instant_articles_api_rules.module, line 86 - Provide Drupal rules to manage facebook instant article using API.
Code
function fb_instant_articles_api_rules_remove_article($node) {
if (isset($node->nid)) {
$url = array();
// We try to depend on $node->path since entity_uri may not be able to
// get the alias if the alias is deleted first.
if (!empty($node->path['alias'])) {
$url['path'] = $node->path['alias'];
}
else {
$url = entity_uri('node', $node);
}
// @see \Drupal\fb_instant_articles_display\EntityPropertyMapper\addCanonicalURL()
$canonical_override = variable_get('fb_instant_articles_canonical_url_override', '');
if (!empty($canonical_override)) {
$url['options']['base_url'] = $canonical_override;
}
$url['options']['absolute'] = TRUE;
$canonical_url = url($url['path'], $url['options']);
$client = \Drupal\fb_instant_articles_api\DrupalClient::get();
$client
->removeArticle($canonical_url);
}
}