Code Duplication    Length = 19-20 lines in 2 locations

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

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