Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tagging of version #37

Closed
marfillaster opened this issue Feb 15, 2013 · 13 comments
Closed

Allow tagging of version #37

marfillaster opened this issue Feb 15, 2013 · 13 comments

Comments

@marfillaster
Copy link

It would be nice to have a particular version tagged similar to git. It doesn't have to be unique.

Then add revertByTag() method to repository class

@rvanlaak
Copy link
Contributor

+1

@andrewtch
Copy link
Contributor

I've been thinking about metadata storage, that would allow storing of tags too, but please provide a code sample on how you imagine that.

@rvanlaak
Copy link
Contributor

What for code sample do you mean? Something like a scenario how to use use this feature?

We'd like to 'mark' an order to a certain tag

  1. when it was paid by a customer,
  2. when the order was completed

It also would be nice if this could work in combination with Symfony's built-in ACL, so something like a PRE_FLUSH Doctrine listener that can make use of those tags/metadata.

@andrewtch
Copy link
Contributor

I was discussing something like that with my colleague before, but we couldn't find a solutions other than

$entity = $repos->find();
$entity->setValue('new value');
$auditManager->attachRevisionmetadata($entity, array('source' => 'xml'));

$em->flush();

which is a very generic way actually. Do you have a better idea?

@rvanlaak
Copy link
Contributor

Don't exactly understand what you're trying to archieve with the code sample you gave. I would expect the $auditManager to have a function like addTag($auditableEntity, $tagName=null) with $tagName as an optional parameter.

If I'm right this could be implemented by adding an extra column to the central revisions table, and adding a function to the manager to getEntityByTag($auditableEntity).

The built-in Bundle views could show the tags in an extra column.

@andrewtch
Copy link
Contributor

Ah, you mean tagging existing revisions after these revisions are saved? I'm talking about attaching arbitrary metadata to entities before flash, which is a more generic way. Which approach suits you most?

@rvanlaak
Copy link
Contributor

Adding metadata (like a tag/name) to the current Unit-of-Work indeed does sound better, as long as the metadata will be unique and it will be possible to get an entity based on a metadata key.

@andrewtch
Copy link
Contributor

Uh-huh. We'll try to mix up something next week.

How do you think is better - adding metas to current revision or per-entity?

@rvanlaak
Copy link
Contributor

You mean the target table for the metadata? I would add it to the revisions table, since it is possible for Doctrine to search in Array types. Tried to find documentation about it, but couldn't find it that fast.

@andrewtch
Copy link
Contributor

I'm thinking about what is better - having a metadata bag for a revision or having an option to add metas to concrete entity.

Array is not much an option - I started hacking EntityAudit since we have to upgrade old project where history audit tables ar ~5m records long (it's a CMS with ~ 5000 pages and ~ 5 years of work).

@andrewtch
Copy link
Contributor

Well, it looks like we need to have something like:

  • AuditManager->addRevisionMeta($key, $value)
  • AuditManager->addEntityMeta(object $entity, $key, $value)

that is persisted in OnFlush and also the following methods:

  • Revision->getRevisionMeta
  • ChangedEntity->getRevisionMeta
  • AuditReader->findRevisionByMeta($key, $value);

@DavidBadura , what do you think?

@OskarStark
Copy link
Member

great idea!

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants