Can a behavior update another model

Trying to get up and running with Yii and despite having read both books, I’m still questioning some of the approaches to take. Today’s issue is whether I could (or should!) define model behaviors that reference / update a second model.

Specifically in my case I have a model that represents an uploaded file. The model currently stores metadata wrt the upload in a table and stores the actual file on disc somewhere. It’s certain that multiple other models in my app may also want to attach a single uploaded file, but they shouldn’t care as to the mechanics (ie how / where the upload is stored etc.).

The way I was envisaging this working is that I could create a behavior to attach to each ‘primary’ model that wanted file upload & storage capability, and include the ID of the upload model as an attribute in the primary model with an appropriate relation. Then the behavior would perform appropriate model operations on the upload model, as they are performed on the primary model (eg delete the upload when the primary row is deleted). Whereas I’m sure I could get this to work, I don’t know if the approach is right or wrong. The only alternative I see is to do the wiring in the controller and repeat for every single model that wants to store uploads.

There is a Yii extension fileimagearbehavior which does a similar thing to what I want, but in their case the behavior handles the file storage itself - there is no second model, so no metadata which is a requirement for me.

Anyone have any feedback or guidance?