Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ayo Adesina 430 posts 1023 karma points
    Feb 01, 2017 @ 16:02
    Ayo Adesina
    0

    Make ContentService.SendToPublication() More Flexible.

    Hi Guys,

    I have been using Umbraco for quite a while now but never actually had a look at the code, but because of a few issues I have been having* I went to git hub and had a look at what actually happens when you call

    ContentService.SendToPublication()

    When this method is called it, it all so calls ContentService.Save() and there is no way of stopping it from raising a Save event....

    public bool SendToPublication(IContent content, int userId = 0)
        {
            if (SendingToPublish.IsRaisedEventCancelled(new SendToPublishEventArgs<IContent>(content), this))
                return false;
    
            //Save before raising event
            Save(content, userId);
    
            SentToPublish.RaiseEvent(new SendToPublishEventArgs<IContent>(content, false), this);
    
            Audit(AuditType.SendToPublish, "Send to Publish performed by user", content.WriterId, content.Id);
    
            return true;
        }
    

    So I suggest, that ContentService.SendToPublication() be changed to accept an optional bool parameter so that you are not forced to raise a save event when you send content to publication.

    So it would would look something like this....

    public bool SendToPublication(IContent content, int userId = 0, bool raiseEvents = true)
    {
        if (SendingToPublish.IsRaisedEventCancelled(new SendToPublishEventArgs<IContent>(content), this))
            return false;
    
        //Save before raising event
        Save(content, userId, raiseEvents);
    
        SentToPublish.RaiseEvent(new SendToPublishEventArgs<IContent>(content, false), this);
    
        Audit(AuditType.SendToPublish, "Send to Publish performed by user", content.WriterId, content.Id);
    
        return true;
    }
    

    What do you think guys?

    *https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/83686-whats-the-difference-between-contentservicesave-and-contentservicesendtopublication

    *https://our.umbraco.org/forum/extending-umbraco-and-using-the-api//83673-contentservicesaveandpublishwithstatus-vs-contentservicesendtopublication

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Feb 09, 2017 @ 03:25
    Shannon Deminick
    0

    Hi,

    Please see this issue here: http://issues.umbraco.org/issue/U4-9490

Please Sign in or register to post replies

Write your reply to:

Draft