本文整理汇总了PHP中ElggEntity::getContainerEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggEntity::getContainerEntity方法的具体用法?PHP ElggEntity::getContainerEntity怎么用?PHP ElggEntity::getContainerEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggEntity
的用法示例。
在下文中一共展示了ElggEntity::getContainerEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: thewire_tools_url_handler
/**
* Custom URL handler for thewire objects
*
* @param ElggEntity $entity the entity to make the URL for
*
* @return string the URL
*/
function thewire_tools_url_handler(ElggEntity $entity)
{
if ($entity->getContainerEntity() instanceof ElggGroup) {
$entity_url = elgg_get_site_url() . "thewire/group/" . $entity->getContainer();
} else {
$entity_url = elgg_get_site_url() . "thewire/owner/" . $entity->getOwnerEntity()->username;
}
return $entity_url;
}
示例2: send_custom_notifications
/**
* Listen to the 'publish','object' event and send out notifications
* to interested users, as well as anyone tagged
*
* @param string $event Equals 'publish'
* @param string $entity_type Equals 'object'
* @param ElggEntity $entity Published entity
*/
function send_custom_notifications($event, $entity_type, $entity)
{
if ($entity->origin !== 'wall') {
return true;
}
// We only want to notify about wire posts and wall posts, all content created therewith is implied
$accepted_subtypes = array('hjwall', 'thewire');
if (!in_array($entity->getSubtype(), $accepted_subtypes)) {
return true;
}
$poster = $entity->getOwnerEntity();
$container = $entity->getContainerEntity();
$message = format_wall_message($entity, true);
$sent = array(elgg_get_logged_in_user_guid(), $poster->guid, $container->guid);
// Notify wall owner
if ($poster->guid !== $container->guid && elgg_instanceof($container, 'user')) {
$to = $container->guid;
$from = $poster->guid;
$target = elgg_echo("wall:target:{$entity->getSubtype()}");
$ownership = elgg_echo('wall:ownership:your', array($target));
$subject = elgg_echo('wall:new:notification:subject', array($poster->name, $ownership));
$summary = elgg_view('output/url', array('text' => $subject, 'href' => $entity->getURL()));
$body = elgg_echo('wall:new:notification:message', array($poster->name, $ownership, $message, $entity->getURL()));
notify_user($to, $from, $subject, $body, array('summary' => $summary, 'object' => $entity, 'action' => 'received'));
}
// Notify tagged users
$tagged_friends = get_tagged_friends($entity);
foreach ($tagged_friends as $tagged_friend) {
// user tagged herself or the wall owner
if ($tagged_friend->guid == $poster->guid || $tagged_friend->guid == $container->guid || in_array($tagged_friend->guid, $sent)) {
continue;
}
$sent[] = $tagged_friend->guid;
$to = $tagged_friend->guid;
$from = $poster->guid;
$subject = elgg_echo('wall:tagged:notification:subject', array($poster->name));
$summary = elgg_view('output/url', array('text' => $subject, 'href' => $entity->getURL()));
$body = elgg_echo('wall:tagged:notification:message', array($poster->name, $message, $entity->getURL()));
notify_user($to, $from, $subject, $body, array('summary' => $summary, 'object' => $entity, 'action' => 'tagged'));
}
return true;
}
示例3: seo_prepare_entity_data
/**
* Prepare entity SEF data
*
* @param \ElggEntity $entity Entity
* @return array|false
*/
function seo_prepare_entity_data(\ElggEntity $entity)
{
$path = seo_get_path($entity->getURL());
if (!$path || $path == '/') {
return false;
}
$type = $entity->getType();
switch ($type) {
case 'user':
if (elgg_is_active_plugin('profile')) {
$sef_path = "/profile/{$entity->username}";
}
break;
case 'group':
$subtype = $entity->getSubtype();
$registered = (array) get_registered_entity_types('group');
if (!$subtype || in_array($subtype, $registered)) {
if ($subtype && elgg_language_key_exists("item:group:{$subtype}", 'en')) {
$prefix = elgg_get_friendly_title(elgg_echo("item:group:{$subtype}", array(), 'en'));
} else {
$prefix = elgg_get_friendly_title(elgg_echo('item:group', array(), 'en'));
}
$friendly_title = elgg_get_friendly_title($entity->getDisplayName() ?: '');
$sef_path = "/{$prefix}/{$entity->guid}-{$friendly_title}";
}
break;
case 'object':
$subtype = $entity->getSubtype();
$registered = (array) get_registered_entity_types('object');
if (in_array($subtype, $registered)) {
if (elgg_language_key_exists("item:object:{$subtype}", 'en')) {
$prefix = elgg_get_friendly_title(elgg_echo("item:object:{$subtype}", array(), 'en'));
} else {
$prefix = elgg_get_friendly_title($subtype);
}
$friendly_title = elgg_get_friendly_title($entity->getDisplayName() ?: '');
$sef_path = "/{$prefix}/{$entity->guid}-{$friendly_title}";
}
break;
}
if (!$sef_path) {
$sef_path = $path;
}
$sef_data = seo_get_data($entity->getURL());
if (!is_array($sef_data)) {
$sef_data = array();
}
$entity_sef_data = ['path' => $path, 'sef_path' => $sef_path, 'title' => $entity->getDisplayName(), 'description' => elgg_get_excerpt($entity->description), 'keywords' => is_array($entity->tags) ? implode(',', $entity->tags) : $entity->tags, 'guid' => $entity->guid];
if ($entity->guid != $entity->owner_guid) {
$owner = $entity->getOwnerEntity();
if ($owner) {
$entity_sef_data['owner'] = seo_prepare_entity_data($owner);
}
}
if ($entity->guid != $entity->container_guid && $entity->owner_guid != $entity->container_guid) {
$container = $entity->getContainerEntity();
if ($container) {
$entity_sef_data['container'] = seo_prepare_entity_data($container);
}
}
if (empty($sef_data['admin_defined'])) {
$sef_data = array_merge($sef_data, $entity_sef_data);
} else {
foreach ($entity_sef_data as $key => $value) {
if (empty($sef_data[$key])) {
$sef_data[$key] = $value;
}
}
}
$entity_sef_metatags = elgg_trigger_plugin_hook('metatags', 'discovery', ['entity' => $entity, 'url' => elgg_normalize_url($sef_path)], []);
if (!empty($entity_sef_metatags)) {
foreach ($entity_sef_metatags as $key => $value) {
if (empty($sef_data['admin_defined']) || empty($sef_data['metatags'][$key])) {
$sef_data['metatags'][$key] = $value;
}
}
}
return $sef_data;
}