Code Duplication    Length = 19-20 lines in 2 locations

src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeAdminPublisher.php 2 locations

@@ 132-151 (lines=20) @@
129
     *
130
     * @throws AccessDeniedException
131
     */
132
    public function publishLater(NodeTranslation $nodeTranslation, \DateTime $date)
133
    {
134
        $node = $nodeTranslation->getNode();
135
        if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_PUBLISH, $node)) {
136
            throw new AccessDeniedException();
137
        }
138
139
        //remove existing first
140
        $this->unSchedulePublish($nodeTranslation);
141
142
        $user = $this->tokenStorage->getToken()->getUser();
143
        $queuedNodeTranslationAction = new QueuedNodeTranslationAction();
144
        $queuedNodeTranslationAction
145
            ->setNodeTranslation($nodeTranslation)
146
            ->setAction(QueuedNodeTranslationAction::ACTION_PUBLISH)
147
            ->setUser($user)
148
            ->setDate($date);
149
        $this->em->persist($queuedNodeTranslationAction);
150
        $this->em->flush();
151
    }
152
153
    /**
154
     * @param NodeTranslation $nodeTranslation
@@ 191-209 (lines=19) @@
188
     *
189
     * @throws AccessDeniedException
190
     */
191
    public function unPublishLater(NodeTranslation $nodeTranslation, \DateTime $date)
192
    {
193
        $node = $nodeTranslation->getNode();
194
        if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_UNPUBLISH, $node)) {
195
            throw new AccessDeniedException();
196
        }
197
198
        //remove existing first
199
        $this->unSchedulePublish($nodeTranslation);
200
        $user = $this->tokenStorage->getToken()->getUser();
201
        $queuedNodeTranslationAction = new QueuedNodeTranslationAction();
202
        $queuedNodeTranslationAction
203
            ->setNodeTranslation($nodeTranslation)
204
            ->setAction(QueuedNodeTranslationAction::ACTION_UNPUBLISH)
205
            ->setUser($user)
206
            ->setDate($date);
207
        $this->em->persist($queuedNodeTranslationAction);
208
        $this->em->flush();
209
    }
210
211
    /**
212
     * @param NodeTranslation $nodeTranslation