本文整理汇总了PHP中ElggEntity::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggEntity::getType方法的具体用法?PHP ElggEntity::getType怎么用?PHP ElggEntity::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggEntity
的用法示例。
在下文中一共展示了ElggEntity::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canReshareEntity
/**
* Check if resharing of this entity is allowed
*
* @param \ElggEntity $entity the entity to check
*
* @return bool
*/
protected static function canReshareEntity(\ElggEntity $entity)
{
if (!$entity instanceof \ElggEntity) {
return false;
}
// only allow objects and groups
if (!$entity instanceof \ElggObject && !$entity instanceof \ElggGroup) {
return false;
}
// comments and discussion replies are never allowed
$blocked_subtypes = ['comment', 'discussion_reply'];
if (in_array($entity->getSubtype(), $blocked_subtypes)) {
return false;
}
// by default allow searchable entities
$reshare_allowed = false;
if ($entity instanceof \ElggGroup) {
$reshare_allowed = true;
} else {
$searchable_entities = get_registered_entity_types($entity->getType());
if (!empty($searchable_entities)) {
$reshare_allowed = in_array($entity->getSubtype(), $searchable_entities);
}
}
// trigger hook to allow others to change
$params = ['entity' => $entity, 'user' => elgg_get_logged_in_user_entity()];
return (bool) elgg_trigger_plugin_hook('reshare', $entity->getType(), $params, $reshare_allowed);
}
示例2: actions_feature_is_allowed_type
/**
* Check if entity type is registered for feature/unfeature
*
* @param ElggEntity $entity Entity to be featured
* @return bool
*/
function actions_feature_is_allowed_type(ElggEntity $entity)
{
$type = $entity->getType();
$subtype = $entity->getSubtype();
$hook_type = implode(':', array_filter([$type, $subtype]));
return elgg_trigger_plugin_hook('feature', $hook_type, ['entity' => $entity], false);
}
示例3: advanced_notifications_is_registered_notification_entity
/**
* Checks if the given $entity is registered for notifications by
* register_notification_object()
*
* @param ElggEntity $entity the entity to check
* @param bool $subject return the subject string (default=false)
*
* @return bool|string
*/
function advanced_notifications_is_registered_notification_entity(ElggEntity $entity, $subject = false)
{
$result = false;
if (!empty($entity) && $entity instanceof ElggEntity) {
$type = $entity->getType();
if (empty($type)) {
$type = "__BLANK__";
}
$subtype = $entity->getSubtype();
if (empty($subtype)) {
$subtype = "__BLANK__";
}
// get the registered entity -> type/subtype
$notifications = elgg_get_config("register_objects");
if (!empty($notifications) && is_array($notifications)) {
if (isset($notifications[$type]) && isset($notifications[$type][$subtype])) {
if ($subject) {
$result = $notifications[$type][$subtype];
} else {
$result = true;
}
}
}
}
return $result;
}
示例4: testSimpleGetters
public function testSimpleGetters()
{
$this->obj->type = 'foo';
$this->obj->subtype = 'subtype';
$this->obj->owner_guid = 77;
$this->obj->access_id = 2;
$this->obj->time_created = 123456789;
$this->assertEquals($this->obj->getGUID(), $this->obj->guid);
$this->assertEquals($this->obj->getType(), $this->obj->type);
// Note: before save() subtype returns string, int after
// see https://github.com/Elgg/Elgg/issues/5920#issuecomment-25246298
$this->assertEquals($this->obj->getSubtype(), $this->obj->subtype);
$this->assertEquals($this->obj->getOwnerGUID(), $this->obj->owner_guid);
$this->assertEquals($this->obj->getAccessID(), $this->obj->access_id);
$this->assertEquals($this->obj->getTimeCreated(), $this->obj->time_created);
$this->assertEquals($this->obj->getTimeUpdated(), $this->obj->time_updated);
}
示例5: events
/**
* Track certain events on ElggEntity's
*
* @param string $event the event
* @param string $type the type of the ElggEntity
* @param \ElggEntity $object the entity for the event
*
* @return void
*/
public static function events($event, $type, $object)
{
if (!$object instanceof \ElggEntity) {
return;
}
if (!analytics_google_track_events_enabled()) {
return;
}
switch ($object->getType()) {
case 'object':
analytics_track_event($object->getSubtype(), $event, $object->title);
break;
case 'group':
case 'user':
analytics_track_event($object->getType(), $event, $object->name);
break;
}
}
示例6: likes_count
/**
* Count how many people have liked an entity.
*
* @param ElggEntity $entity
*
* @return int Number of likes
*/
function likes_count($entity)
{
$type = $entity->getType();
$params = array('entity' => $entity);
$number = elgg_trigger_plugin_hook('likes:count', $type, $params, false);
if ($number) {
return $number;
} else {
return $entity->countAnnotations('likes');
}
}
示例7: hj_framework_set_entity_priority
/**
* Set priority of an element in a list
*
* @see ElggEntity::$priority
*
* @param ElggEntity $entity
* @return bool
*/
function hj_framework_set_entity_priority($entity, $priority = null)
{
if ($priority) {
$entity->priority = $priority;
return true;
}
$count = elgg_get_entities(array('type' => $entity->getType(), 'subtype' => $entity->getSubtype(), 'owner_guid' => $entity->owner_guid, 'container_guid' => $entity->container_guid, 'count' => true));
if (!$entity->priority) {
$entity->priority = $count + 1;
}
return true;
}
示例8: getObjectType
/**
* Prepares object type string
* @return string
*/
public function getObjectType()
{
$type = $this->object->getType();
$subtype = $this->object->getSubtype() ?: 'default';
$keys = ["interactions:{$type}:{$subtype}", $this->object instanceof Comment ? "interactions:comment" : "interactions:post"];
foreach ($keys as $key) {
if (elgg_language_key_exists($key, $this->language)) {
return elgg_echo($key, array(), $this->language);
}
}
return elgg_echo('interactions:post', $this->language);
}
示例9: testSimpleGetters
/**
* @requires PHP 5.3.2
*/
public function testSimpleGetters()
{
$this->obj->type = 'foo';
$this->obj->subtype = 'subtype';
$this->obj->owner_guid = 77;
$this->obj->access_id = 2;
$this->obj->time_created = 123456789;
$this->assertEquals($this->obj->getGUID(), $this->obj->guid);
$this->assertEquals($this->obj->getType(), $this->obj->type);
$this->assertEquals($this->obj->getSubtype(), $this->obj->subtype);
$this->assertEquals($this->obj->getOwnerGUID(), $this->obj->owner_guid);
$this->assertEquals($this->obj->getAccessID(), $this->obj->access_id);
$this->assertEquals($this->obj->getTimeCreated(), $this->obj->time_created);
$this->assertEquals($this->obj->getTimeUpdated(), $this->obj->time_updated);
}
示例10: getValues
/**
* {@inheritdoc}
*/
public function getValues(\ElggEntity $entity)
{
$sticky = $this->getStickyValue();
if ($sticky) {
return $sticky;
}
$name = $this->getShortname();
switch ($name) {
default:
return $entity->{$name} ?: $this->getDefaultValue();
case 'type':
return $entity->getType();
case 'subtype':
return $entity->getSubtype();
}
}
示例11: evan_user_can
function evan_user_can($verb, Entity $object, Entity $target = NULL)
{
switch ($verb) {
case 'post':
if (!$target) {
$target = elgg_get_logged_in_user_entity();
}
$result = $target->canWriteToContainer(0, $object->getType(), $object->getSubtype());
break;
case 'update':
$result = $object->canEdit();
break;
default:
$result = false;
break;
}
return elgg_trigger_plugin_hook("permission", $verb, array('actor' => elgg_get_logged_in_user_entity(), 'verb' => $verb, 'object' => $object, 'target' => $target), $result);
}
示例12: getAttributeNames
/**
* Returns attribute names for an entity
*
* @param ElggEntity $entity Entity
* @return array
*/
public function getAttributeNames($entity)
{
if (!$entity instanceof \ElggEntity) {
return array();
}
$default = array('guid', 'type', 'subtype', 'owner_guid', 'container_guid', 'site_guid', 'access_id', 'time_created', 'time_updated', 'last_action', 'enabled');
switch ($entity->getType()) {
case 'user':
$attributes = array('name', 'username', 'email', 'language', 'banned', 'admin', 'password', 'salt');
break;
case 'group':
$attributes = array('name', 'description');
break;
case 'object':
$attributes = array('title', 'description');
break;
}
return array_merge($default, $attributes);
}
示例13: elgg_media_get_thumb_sizes
/**
* Checks if media type is allowed for given entity
*
* @param \ElggEntity $entity Entity
* @param string $type Media type
* @return bool
*/
function elgg_media_get_thumb_sizes(\ElggEntity $entity, $type = 'icon')
{
$hook_type = implode(':', array_filter([$entity->getType(), $entity->getSubtype()]));
$hook_params = ['type' => $type, 'entity' => $entity];
return elgg_trigger_plugin_hook("entity:{$type}:sizes", $hook_type, $hook_params, []);
}
示例14: entity_view_counter_is_counted
function entity_view_counter_is_counted(ElggEntity $entity)
{
if (php_sapi_name() === 'cli') {
return true;
}
if (!entity_view_counter_is_configured_entity_type($entity->getType(), $entity->getSubtype())) {
return true;
}
if (isset($_SERVER["HTTP_USER_AGENT"]) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER["HTTP_USER_AGENT"])) {
return true;
}
$user = elgg_get_logged_in_user_entity();
if ($user && $user->getGUID() == $entity->getOwnerGUID()) {
return true;
}
if (is_memcache_available()) {
$cache = new ElggMemcache('entity_view_counter');
$key = "view_" . session_id() . "_" . $entity->guid;
if ($cache->load($key)) {
return true;
}
}
if (entity_view_counter_ignore_ip()) {
return true;
}
return false;
}
示例15: getDocumentTypeFromEntity
public function getDocumentTypeFromEntity(\ElggEntity $entity)
{
$type = $entity->getType();
$subtype = $entity->getSubType();
if (empty($subtype)) {
return "{$type}";
}
return "{$type}.{$subtype}";
}