Completed
Push — SWP-2317 ( 73b50b...4633c4 )
by
unknown
54s
created
src/SWP/Bundle/ContentBundle/Model/ArticleInterface.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -25,166 +25,166 @@
 block discarded – undo
25 25
 use SWP\Component\Storage\Model\PersistableInterface;
26 26
 
27 27
 interface ArticleInterface extends TimestampableInterface, TimestampableCancelInterface, RuleSubjectInterface, TranslatableInterface, PersistableInterface, SoftDeletableInterface, MetadataAwareInterface, MediaAwareInterface, AuthorsAwareInterface, KeywordAwareInterface, RelatedArticlesAwareInterface, SeoMetadataAwareInterface {
28
-  const STATUS_NEW = 'new';
29
-
30
-  const STATUS_PUBLISHED = 'published';
31
-
32
-  const STATUS_UNPUBLISHED = 'unpublished';
33
-
34
-  const STATUS_CANCELED = 'canceled';
35
-
36
-  /**
37
-   * @return mixed
38
-   */
39
-  public function getId();
40
-
41
-  /**
42
-   * @return string
43
-   */
44
-  public function getBody();
45
-
46
-  /**
47
-   * @param string $body
48
-   */
49
-  public function setBody($body);
28
+    const STATUS_NEW = 'new';
29
+
30
+    const STATUS_PUBLISHED = 'published';
31
+
32
+    const STATUS_UNPUBLISHED = 'unpublished';
33
+
34
+    const STATUS_CANCELED = 'canceled';
35
+
36
+    /**
37
+     * @return mixed
38
+     */
39
+    public function getId();
40
+
41
+    /**
42
+     * @return string
43
+     */
44
+    public function getBody();
45
+
46
+    /**
47
+     * @param string $body
48
+     */
49
+    public function setBody($body);
50 50
 
51
-  /**
52
-   * @return string
53
-   */
54
-  public function getTitle();
51
+    /**
52
+     * @return string
53
+     */
54
+    public function getTitle();
55 55
 
56
-  /**
57
-   * @param string $title
58
-   */
59
-  public function setTitle($title);
56
+    /**
57
+     * @param string $title
58
+     */
59
+    public function setTitle($title);
60 60
 
61
-  /**
62
-   * @return string
63
-   */
64
-  public function getSlug();
61
+    /**
62
+     * @return string
63
+     */
64
+    public function getSlug();
65 65
 
66
-  /**
67
-   * @param string $slug
68
-   */
69
-  public function setSlug($slug);
66
+    /**
67
+     * @param string $slug
68
+     */
69
+    public function setSlug($slug);
70 70
 
71
-  /**
72
-   * @return \DateTime
73
-   */
74
-  public function getPublishedAt();
71
+    /**
72
+     * @return \DateTime
73
+     */
74
+    public function getPublishedAt();
75 75
 
76
-  /**
77
-   * @param string $publishedAt
78
-   *
79
-   * @return \DateTime
80
-   */
81
-  public function setPublishedAt(?\DateTime $publishedAt);
76
+    /**
77
+     * @param string $publishedAt
78
+     *
79
+     * @return \DateTime
80
+     */
81
+    public function setPublishedAt(?\DateTime $publishedAt);
82 82
 
83
-  /**
84
-   * @return bool
85
-   */
86
-  public function isPublished();
83
+    /**
84
+     * @return bool
85
+     */
86
+    public function isPublished();
87 87
 
88
-  /**
89
-   * @param string $status
90
-   *
91
-   * @return string
92
-   */
93
-  public function setStatus($status);
88
+    /**
89
+     * @param string $status
90
+     *
91
+     * @return string
92
+     */
93
+    public function setStatus($status);
94 94
 
95
-  /**
96
-   * @return string
97
-   */
98
-  public function getStatus();
95
+    /**
96
+     * @return string
97
+     */
98
+    public function getStatus();
99 99
 
100
-  /**
101
-   * @return string
102
-   */
103
-  public function getTemplateName();
100
+    /**
101
+     * @return string
102
+     */
103
+    public function getTemplateName();
104 104
 
105
-  /**
106
-   * @param string $templateName
107
-   */
108
-  public function setTemplateName($templateName);
105
+    /**
106
+     * @param string $templateName
107
+     */
108
+    public function setTemplateName($templateName);
109 109
 
110
-  /**
111
-   * @param RouteInterface|void $route
112
-   */
113
-  public function setRoute(RouteInterface $route = null);
110
+    /**
111
+     * @param RouteInterface|void $route
112
+     */
113
+    public function setRoute(RouteInterface $route = null);
114 114
 
115
-  /**
116
-   * @return RouteInterface
117
-   */
118
-  public function getRoute();
115
+    /**
116
+     * @return RouteInterface
117
+     */
118
+    public function getRoute();
119 119
 
120
-  /**
121
-   * @return string
122
-   */
123
-  public function getLead();
120
+    /**
121
+     * @return string
122
+     */
123
+    public function getLead();
124 124
 
125
-  /**
126
-   * @param string $lead
127
-   */
128
-  public function setLead($lead);
125
+    /**
126
+     * @param string $lead
127
+     */
128
+    public function setLead($lead);
129 129
 
130
-  public function getCode(): string;
130
+    public function getCode(): string;
131 131
 
132
-  public function setCode(string $code);
132
+    public function setCode(string $code);
133 133
 
134
-  public function addSourceReference(ArticleSourceReferenceInterface $source);
134
+    public function addSourceReference(ArticleSourceReferenceInterface $source);
135 135
 
136
-  public function removeSourceReference(ArticleSourceReferenceInterface $source);
136
+    public function removeSourceReference(ArticleSourceReferenceInterface $source);
137 137
 
138
-  public function hasSourceReference(ArticleSourceReferenceInterface $source): bool;
138
+    public function hasSourceReference(ArticleSourceReferenceInterface $source): bool;
139 139
 
140
-  /**
141
-   * @return Collection|ArticleSourceReferenceInterface[]
142
-   */
143
-  public function getSources(): Collection;
140
+    /**
141
+     * @return Collection|ArticleSourceReferenceInterface[]
142
+     */
143
+    public function getSources(): Collection;
144 144
 
145
-  public function getExtra(): array;
145
+    public function getExtra(): array;
146 146
 
147
-  public function setExtra(?array $extra): void;
147
+    public function setExtra(?array $extra): void;
148 148
 
149
-  public function getSlideshows(): Collection;
149
+    public function getSlideshows(): Collection;
150 150
 
151
-  public function hasSlideshow(SlideshowInterface $slideshow): bool;
151
+    public function hasSlideshow(SlideshowInterface $slideshow): bool;
152 152
 
153
-  public function addSlideshow(SlideshowInterface $slideshow): void;
153
+    public function addSlideshow(SlideshowInterface $slideshow): void;
154 154
 
155
-  public function removeSlideshow(SlideshowInterface $slideshow): void;
155
+    public function removeSlideshow(SlideshowInterface $slideshow): void;
156 156
 
157
-  public function getPreviousRelativeUrl(): Collection;
157
+    public function getPreviousRelativeUrl(): Collection;
158 158
 
159
-  public function hasPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): bool;
159
+    public function hasPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): bool;
160 160
 
161
-  public function addPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void;
161
+    public function addPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void;
162 162
 
163
-  public function removePreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void;
163
+    public function removePreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void;
164 164
 
165
-  public function getData(): ?MetadataInterface;
165
+    public function getData(): ?MetadataInterface;
166 166
 
167
-  public function setData(?MetadataInterface $metadata): void;
167
+    public function setData(?MetadataInterface $metadata): void;
168 168
 
169
-  public function getExtraTextFields(): Collection;
169
+    public function getExtraTextFields(): Collection;
170 170
 
171
-  public function getExtraEmbedFields(): Collection;
171
+    public function getExtraEmbedFields(): Collection;
172 172
 
173
-  public function setExtraFields(array $extra): void;
173
+    public function setExtraFields(array $extra): void;
174 174
 
175
-  public function getExtraByKey(string $key): ?ArticleExtraFieldInterface;
175
+    public function getExtraByKey(string $key): ?ArticleExtraFieldInterface;
176 176
 
177
-  public function getExtraArray(): array;
177
+    public function getExtraArray(): array;
178 178
 
179
-  public function isPublishable(): bool;
179
+    public function isPublishable(): bool;
180 180
 
181
-  public function setPublishable(bool $boolean): void;
181
+    public function setPublishable(bool $boolean): void;
182 182
 
183
-  public function setPublishStartDate(\DateTime $startDate = null);
183
+    public function setPublishStartDate(\DateTime $startDate = null);
184 184
 
185
-  public function getPublishStartDate();
185
+    public function getPublishStartDate();
186 186
 
187
-  public function setPublishEndDate(\DateTime $endDate = null);
187
+    public function setPublishEndDate(\DateTime $endDate = null);
188 188
 
189
-  public function getPublishEndDate();
189
+    public function getPublishEndDate();
190 190
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/ContentBundle/Controller/ArticleController.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
 
38 38
 class ArticleController extends AbstractController {
39 39
 
40
-  private FormFactoryInterface $formFactory;
41
-  private RouteProviderInterface $routeProvider; // swp.provider.route
42
-  private ArticleRepositoryInterface $articleRepository; //swp.repository.article
43
-  private ArticleProviderInterface $articleProvider; //swp.provider.article
44
-  private EventDispatcherInterface  $eventDispatcher;
45
-  private EntityManagerInterface $entityManager; // swp.object_manager.article
46
-  private ArticleServiceInterface $articleService; // swp.service.article
47
-  private PackageRepositoryInterface $packageRepository;
48
-
49
-  /**
50
-   * @param FormFactoryInterface $formFactory
51
-   * @param RouteProviderInterface $routeProvider
52
-   * @param ArticleRepositoryInterface $articleRepository
53
-   * @param ArticleProviderInterface $articleProvider
54
-   * @param EventDispatcherInterface $eventDispatcher
55
-   * @param EntityManagerInterface $entityManager
56
-   * @param ArticleServiceInterface $articleService
57
-   * @param PackageRepositoryInterface $packageRepository
58
-   */
59
-  public function __construct(FormFactoryInterface       $formFactory, RouteProviderInterface $routeProvider,
60
-                              ArticleRepositoryInterface $articleRepository, ArticleProviderInterface $articleProvider,
61
-                              EventDispatcherInterface   $eventDispatcher, EntityManagerInterface $entityManager,
62
-                              ArticleServiceInterface    $articleService, PackageRepositoryInterface   $packageRepository) {
40
+    private FormFactoryInterface $formFactory;
41
+    private RouteProviderInterface $routeProvider; // swp.provider.route
42
+    private ArticleRepositoryInterface $articleRepository; //swp.repository.article
43
+    private ArticleProviderInterface $articleProvider; //swp.provider.article
44
+    private EventDispatcherInterface  $eventDispatcher;
45
+    private EntityManagerInterface $entityManager; // swp.object_manager.article
46
+    private ArticleServiceInterface $articleService; // swp.service.article
47
+    private PackageRepositoryInterface $packageRepository;
48
+
49
+    /**
50
+     * @param FormFactoryInterface $formFactory
51
+     * @param RouteProviderInterface $routeProvider
52
+     * @param ArticleRepositoryInterface $articleRepository
53
+     * @param ArticleProviderInterface $articleProvider
54
+     * @param EventDispatcherInterface $eventDispatcher
55
+     * @param EntityManagerInterface $entityManager
56
+     * @param ArticleServiceInterface $articleService
57
+     * @param PackageRepositoryInterface $packageRepository
58
+     */
59
+    public function __construct(FormFactoryInterface       $formFactory, RouteProviderInterface $routeProvider,
60
+                                ArticleRepositoryInterface $articleRepository, ArticleProviderInterface $articleProvider,
61
+                                EventDispatcherInterface   $eventDispatcher, EntityManagerInterface $entityManager,
62
+                                ArticleServiceInterface    $articleService, PackageRepositoryInterface   $packageRepository) {
63 63
     $this->formFactory = $formFactory;
64 64
     $this->routeProvider = $routeProvider;
65 65
     $this->articleRepository = $articleRepository;
@@ -68,30 +68,30 @@  discard block
 block discarded – undo
68 68
     $this->entityManager = $entityManager;
69 69
     $this->articleService = $articleService;
70 70
     $this->packageRepository = $packageRepository;
71
-  }
71
+    }
72 72
 
73 73
 
74
-  /**
75
-   * @Route("/api/{version}/content/articles/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_list_articles")
76
-   *
77
-   * @throws \Exception
78
-   */
79
-  public function listAction(Request $request): ResourcesListResponseInterface {
74
+    /**
75
+     * @Route("/api/{version}/content/articles/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_list_articles")
76
+     *
77
+     * @throws \Exception
78
+     */
79
+    public function listAction(Request $request): ResourcesListResponseInterface {
80 80
     $authors = '';
81 81
     if (null !== $request->query->get('author', null)) {
82
-      $authors = explode(', ', $request->query->get('author'));
82
+        $authors = explode(', ', $request->query->get('author'));
83 83
     }
84 84
 
85 85
     if ($request->query->get('route', false) && $request->query->get('includeSubRoutes', false)) {
86
-      $routeObject = $this->routeProvider->getOneById($request->query->get('route'));
86
+        $routeObject = $this->routeProvider->getOneById($request->query->get('route'));
87 87
 
88
-      if (null !== $routeObject) {
88
+        if (null !== $routeObject) {
89 89
         $ids = [$routeObject->getId()];
90 90
         foreach ($routeObject->getChildren() as $child) {
91
-          $ids[] = $child->getId();
91
+            $ids[] = $child->getId();
92 92
         }
93 93
         $request->query->set('route', $ids);
94
-      }
94
+        }
95 95
     }
96 96
 
97 97
     $articles = $this->articleRepository
@@ -106,25 +106,25 @@  discard block
 block discarded – undo
106 106
         ]), $request->query->all('sorting'), new PaginationData($request));
107 107
 
108 108
     return new ResourcesListResponse($articles);
109
-  }
109
+    }
110 110
 
111
-  /**
112
-   * @Route("/api/{version}/content/articles/{id}", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_show_articles", requirements={"id"=".+"})
113
-   */
114
-  public function getAction($id): SingleResourceResponseInterface {
111
+    /**
112
+     * @Route("/api/{version}/content/articles/{id}", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_show_articles", requirements={"id"=".+"})
113
+     */
114
+    public function getAction($id): SingleResourceResponseInterface {
115 115
     $article = $this->articleProvider->getOneById($id);
116 116
 
117 117
     if (null === $article) {
118
-      throw new NotFoundHttpException('Article was not found');
118
+        throw new NotFoundHttpException('Article was not found');
119 119
     }
120 120
 
121 121
     return new SingleResourceResponse($article);
122
-  }
122
+    }
123 123
 
124
-  /**
125
-   * @Route("/api/{version}/content/article/search-code", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_show_articles_by_code", requirements={"code"=".+"})
126
-   */
127
-  public function getByCodeAction(Request $request): SingleResourceResponseInterface {
124
+    /**
125
+     * @Route("/api/{version}/content/article/search-code", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_show_articles_by_code", requirements={"code"=".+"})
126
+     */
127
+    public function getByCodeAction(Request $request): SingleResourceResponseInterface {
128 128
     // Extract parameters from the request
129 129
     $code = $request->query->get('code', '');
130 130
     $articleId = $this->entityManager->createQuery('SELECT a.id FROM SWP\Bundle\ContentBundle\Model\Article a where a.code = :code')
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
         ->setMaxResults(1)
133 133
         ->getOneOrNullResult();
134 134
 
135
-      $article = $this->articleProvider->getOneById($articleId);
135
+        $article = $this->articleProvider->getOneById($articleId);
136 136
 
137 137
     if (null === $article) {
138
-      throw new NotFoundHttpException('Article was not found');
138
+        throw new NotFoundHttpException('Article was not found');
139 139
     }
140 140
 
141 141
     $article->setStatus('new');
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
     }
157 157
 
158 158
     return new SingleResourceResponse($article);
159
-  }
159
+    }
160 160
 
161
-  /**
162
-   * @Route("/api/{version}/content/articles/{id}", methods={"PATCH"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_update_articles", requirements={"id"=".+"})
163
-   */
164
-  public function updateAction(Request $request, $id): SingleResourceResponseInterface {
161
+    /**
162
+     * @Route("/api/{version}/content/articles/{id}", methods={"PATCH"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_update_articles", requirements={"id"=".+"})
163
+     */
164
+    public function updateAction(Request $request, $id): SingleResourceResponseInterface {
165 165
     $objectManager = $this->entityManager;
166 166
     $article = $this->findOr404($id);
167 167
     $originalArticleStatus = $article->getStatus();
@@ -170,32 +170,32 @@  discard block
 block discarded – undo
170 170
 
171 171
     $form->handleRequest($request);
172 172
     if ($form->isSubmitted() && $form->isValid()) {
173
-      $this->articleService->reactOnStatusChange($originalArticleStatus, $article);
174
-      $objectManager->flush();
175
-      $objectManager->refresh($article);
173
+        $this->articleService->reactOnStatusChange($originalArticleStatus, $article);
174
+        $objectManager->flush();
175
+        $objectManager->refresh($article);
176 176
 
177
-      return new SingleResourceResponse($article);
177
+        return new SingleResourceResponse($article);
178 178
     }
179 179
 
180 180
     return new SingleResourceResponse($form, new ResponseContext(500));
181
-  }
181
+    }
182 182
 
183
-  /**
184
-   * @Route("/api/{version}/content/articles/{id}", methods={"DELETE"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_delete_articles", requirements={"id"=".+"})
185
-   */
186
-  public function deleteAction($id): SingleResourceResponseInterface {
183
+    /**
184
+     * @Route("/api/{version}/content/articles/{id}", methods={"DELETE"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_delete_articles", requirements={"id"=".+"})
185
+     */
186
+    public function deleteAction($id): SingleResourceResponseInterface {
187 187
     $objectManager = $this->entityManager;
188 188
     $objectManager->remove($this->findOr404($id));
189 189
     $objectManager->flush();
190 190
 
191 191
     return new SingleResourceResponse(null, new ResponseContext(204));
192
-  }
192
+    }
193 193
 
194
-  private function findOr404($id) {
194
+    private function findOr404($id) {
195 195
     if (null === $article = $this->articleProvider->getOneById($id)) {
196
-      throw new NotFoundHttpException('Article was not found.');
196
+        throw new NotFoundHttpException('Article was not found.');
197 197
     }
198 198
 
199 199
     return $article;
200
-  }
200
+    }
201 201
 }
Please login to merge, or discard this patch.