本文整理汇总了PHP中ElggObject::getOriginalAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::getOriginalAttributes方法的具体用法?PHP ElggObject::getOriginalAttributes怎么用?PHP ElggObject::getOriginalAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggObject
的用法示例。
在下文中一共展示了ElggObject::getOriginalAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateQuestion
/**
* After the question is updated in the databse make sure the answers have the same access_id
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param \ElggObject $entity the affected object
*
* @return void
*/
public static function updateQuestion($event, $type, $entity)
{
if (!$entity instanceof \ElggQuestion) {
return;
}
$org_attributes = $entity->getOriginalAttributes();
if (elgg_extract('access_id', $org_attributes) === null) {
// access wasn't updated
return;
}
// ignore access for this part
$ia = elgg_set_ignore_access(true);
// get all the answers for this question
$answers = $entity->getAnswers(['limit' => false]);
if (empty($answers)) {
// restore access
elgg_set_ignore_access($ia);
return;
}
/* @var $answer \ElggAnswer */
foreach ($answers as $answer) {
// update the access_id with the questions access_id
$answer->access_id = $entity->access_id;
$answer->save();
}
// restore access
elgg_set_ignore_access($ia);
}
示例2: updateEvent
/**
* After the event is updated in the database make sure the owned entities have the same access_id
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param \ElggObject $entity the affected object
*
* @return void
*/
public static function updateEvent($event, $type, $entity)
{
if (!$entity instanceof \Event) {
return;
}
$org_attributes = $entity->getOriginalAttributes();
if (elgg_extract('access_id', $org_attributes) === null) {
// access wasn't updated
return;
}
// ignore access for this part
$ia = elgg_set_ignore_access(true);
$days = $entity->getEventDays();
if (!empty($days)) {
foreach ($days as $day) {
$day->access_id = $entity->access_id;
$day->save();
$slots = $day->getEventSlots();
if (empty($slots)) {
continue;
}
foreach ($slots as $slot) {
$slot->access_id = $entity->access_id;
$slot->save();
}
}
}
$questions = $entity->getRegistrationFormQuestions();
if (!empty($questions)) {
foreach ($questions as $question) {
$question->access_id = $entity->access_id;
$question->save();
}
}
// restore access
elgg_set_ignore_access($ia);
}
示例3: testMultipleAttributeSetsDontOverwriteOriginals
public function testMultipleAttributeSetsDontOverwriteOriginals()
{
$this->entity->title = 'Foo';
$this->entity->title = 'Bar';
$this->assertEqual($this->entity->getOriginalAttributes(), ['title' => null]);
}
示例4: _elgg_filestore_move_icons
/**
* Listen to entity ownership changes and update icon ownership by moving
* icons to their new owner's directory on filestore.
*
* This will only transfer icons that have a custom location on filestore
* and are owned by the entity's owner (instead of the entity itself).
* Even though core icon service does not store icons in the entity's owner
* directory, there are plugins that do (e.g. file plugin) - this handler
* helps such plugins avoid ownership mismatch.
*
* @param string $event "update:after"
* @param string $type "object"|"group"
* @param ElggObject $entity Entity
* @return void
* @access private
*/
function _elgg_filestore_move_icons($event, $type, $entity)
{
$original_attributes = $entity->getOriginalAttributes();
if (empty($original_attributes['owner_guid'])) {
return;
}
$previous_owner_guid = $original_attributes['owner_guid'];
$new_owner_guid = $entity->owner_guid;
$sizes = elgg_get_icon_sizes($entity->getType(), $entity->getSubtype());
foreach ($sizes as $size => $opts) {
$new_icon = $entity->getIcon($size);
if ($new_icon->owner_guid == $entity->guid) {
// we do not need to update icons that are owned by the entity itself
continue;
}
if ($new_icon->owner_guid != $new_owner_guid) {
// a plugin implements some custom logic
continue;
}
$old_icon = new \ElggIcon();
$old_icon->owner_guid = $previous_owner_guid;
$old_icon->setFilename($new_icon->getFilename());
if (!$old_icon->exists()) {
// there is no icon to move
continue;
}
if ($new_icon->exists()) {
// there is already a new icon
// just removing the old one
$old_icon->delete();
elgg_log("Entity {$entity->guid} has been transferred to a new owner but an icon was left behind under {$old_icon->getFilenameOnFilestore()}. " . "Old icon has been deleted", 'NOTICE');
continue;
}
$old_icon->transfer($new_icon->owner_guid, $new_icon->getFilename());
elgg_log("Entity {$entity->guid} has been transferred to a new owner. " . "Icon was moved from {$old_icon->getFilenameOnFilestore()} to {$new_icon->getFilenameOnFilestore()}.", 'NOTICE');
}
}