XF 2.1 RM should save time() for last_update when edited

Robert9

Well-known member
I dont use upgrade for the RM, i just edit. With every edit i want to have an update for

$resource->last_update = time();

I have solved this by changing the code itself. Now i try to to do an add-on for this.

I have extended

namespace XFRM\Pub\Controller;
class ResourceItem
public function actionEdit(ParameterBag $params)


Now i dont know what to do.

1. I should call the parent.

2. Then i need something like:
is saved? ($editor->save();
or
is redirected? ( return $this->redirect($this->buildLink('resources', $resource, [ ...)

or should i replace the whole method with my own?
 
I want that field!
But i thought too complicated.

Everything to do is to set the new value to
$resource->last_update = time();

Extend:
<extension from_class="XFRM\Pub\Controller\ResourceItem" to_class="Robert9\Ants\XFRM\Pub\Controller\ResourceItem" execute_order="10" active="1"/>

Class, method:
Code:
<?php

namespace Robert9\Ants\XFRM\Pub\Controller;
use XF\Mvc\ParameterBag;

class ResourceItem extends XFCP_ResourceItem {

    public function actionEdit(ParameterBag $params)
    {
        $resource = $this->assertViewableResource($params->resource_id);
        $resource->last_update = time();

        return parent::actionEdit($params);
    }
}

Because i sort resources at the index by this field last_update; everything edited is now at the top.
 
Top Bottom