本文整理汇总了PHP中Idno\Common\Entity::getContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getContentType方法的具体用法?PHP Entity::getContentType怎么用?PHP Entity::getContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Idno\Common\Entity
的用法示例。
在下文中一共展示了Entity::getContentType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publish
/**
* If this Known installation has a PubSubHubbub hub, send a publish notification to the hub
* @param \Idno\Common\Entity $object
* @return array
*/
static function publish($object)
{
if ($hub = Idno::site()->config()->hub) {
$base = Idno::site()->config()->getDisplayURL();
$feeds = array();
// Check to make sure there's an entity
if (!$object instanceof Entity) {
return false;
}
// homepage feed
$homepage_types = Idno::site()->config()->getHomepageContentTypes();
$type_in_homepage = false;
if ($object instanceof Entity) {
if ($object->getContentType() && in_array($object->getContentType()->getEntityClass(), $homepage_types)) {
$type_in_homepage = true;
}
}
if (empty($homepage_types) || $type_in_homepage) {
$feeds[] = $base;
}
// type-specific feeds
if ($object instanceof Entity) {
$feeds[] = $base . 'content/' . $object->getContentTypeCategorySlug() . '/';
}
$feeds[] = $base . 'content/all/';
// tag feeds
foreach ($object->getTags() as $tag) {
$feeds[] = $base . 'tag/' . $tag;
}
if (!empty($feeds)) {
// encode the feeds and their RSS counterparts
$encurls = array();
foreach ($feeds as $feed) {
$encurls[] = urlencode($feed);
$encurls[] = urlencode(Idno::site()->template()->getURLWithVar('_t', 'rss', $feed));
}
$formdata = 'hub.mode=publish&hub.url=' . implode(',', $encurls);
Idno::site()->logging()->info('Pinging ' . $hub . ' with data ' . $formdata);
Webservice::post($hub, $formdata, array('Content-Type' => 'application/x-www-form-urlencoded'));
}
return true;
}
return false;
}