OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Assign attachments from one entity to another

This topic contains 6 replies, has 3 voices, and was last updated by  ant-workaholic 8 years, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34000

    ant-workaholic
    Participant

    Hello, Oro guys. I need your advise, how I can implement this. Now I have custom entity called “Atwork” which contains some attachments (in my case some images and files). I have created workflow for this entity (where manager can upload this files) as a result of this workflow I create new object of another custom entity (which called “Proofing”). Inside Proofing I also have attachments and I should have attachments which were added to “Atwork” too. Please, give me advise how I can implements this by the good way. (Maybe it is possible to do this inside workflow through custom transition or by another way).. Thank you very much.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #34001

    Artem Liubeznyi
    Spectator

    Hi Igor,

    Have you checked our implementation of re-attaching files from a record to the email sent as activity from this record, or vice versa? Your case looks very similar to it.

    #34002

    ant-workaholic
    Participant

    I guess, no. Where I can find this? In which bundle? Thank you.

    #34003

    Yevhen Shyshkin
    Participant

    Hello.

    Probably, you should create custom workflow action for it using AttachmentManager::copyAttachmentFile method. For custom action manual see this topic.

    If you still have issues after all that – feel free to post them here.

    #34004

    ant-workaholic
    Participant

    Thank you for advise.
    Now, I have created new action in which I get my “Atwork” entity and get all attachments by this way:

    $attachments = $this->_attachmentProvider->getEntityAttachments($mainEntity);

    The property $_attachmentProvider I have injected using constructor injection and this is Oro\Bundle\AttachmentBundle\Provider\AttachmentProvider.
    The variable $attacments now consist of array of Attachment objects. But for AttachmentManager::copyAttachmentFile as I see, I need provide File object, I can get this for each attachment separately, I guess. AttachmentManager::copyAttachmentFile will return copy of my attachment file. And now I just need to attach copy of this files to my “Proofing” entity. How I can do this by simple way? Is my thoughts correct? Thank you.

    #34005

    Yevhen Shyshkin
    Participant

    Please, check this example – it makes copy of an entity, but basic idea just the same.

    #34006

    ant-workaholic
    Participant

    Thank you, Yevhen!

Viewing 6 replies - 1 through 6 (of 6 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top