PostFactory exception fix.
This commit is contained in:
parent
bdbcf14a15
commit
fbea7ffe4e
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog;
|
||||||
|
|
||||||
|
class FactoryException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog;
|
||||||
|
|
||||||
|
class InvalidDataException extends FactoryException
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Skobkin\Bundle\PointToolsBundle\Service\Exceptions\Factory\Blogs;
|
namespace Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog;
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\Post;
|
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\Post;
|
||||||
|
|
||||||
class InvalidPostDataException extends \Exception
|
class InvalidPostDataException extends InvalidDataException
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Post
|
* @var Post
|
||||||
|
@ -23,7 +22,7 @@ class InvalidPostDataException extends \Exception
|
||||||
/**
|
/**
|
||||||
* @return Post
|
* @return Post
|
||||||
*/
|
*/
|
||||||
public function getPost()
|
public function getPost(): Post
|
||||||
{
|
{
|
||||||
return $this->post;
|
return $this->post;
|
||||||
}
|
}
|
|
@ -9,8 +9,9 @@ use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\MetaPost;
|
||||||
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\PostsPage;
|
use Skobkin\Bundle\PointToolsBundle\DTO\Api\Crawler\PostsPage;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
|
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostTag;
|
use Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostTag;
|
||||||
|
use Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog\InvalidDataException;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\ApiException;
|
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\ApiException;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\Factory\Blogs\InvalidPostDataException;
|
use Skobkin\Bundle\PointToolsBundle\Exception\Factory\Blog\InvalidPostDataException;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\InvalidResponseException;
|
use Skobkin\Bundle\PointToolsBundle\Service\Exceptions\InvalidResponseException;
|
||||||
use Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory;
|
use Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory;
|
||||||
|
|
||||||
|
@ -115,13 +116,12 @@ class PostFactory
|
||||||
* @return Post
|
* @return Post
|
||||||
*
|
*
|
||||||
* @throws ApiException
|
* @throws ApiException
|
||||||
* @throws InvalidPostDataException
|
* @throws InvalidDataException
|
||||||
*/
|
*/
|
||||||
private function createFromDTO(MetaPost $postData): Post
|
private function createFromDTO(MetaPost $postData): Post
|
||||||
{
|
{
|
||||||
if (!$this->validateMetaPost($postData)) {
|
if (!$this->validateMetaPost($postData)) {
|
||||||
// FIXME
|
throw new InvalidDataException('Invalid post data');
|
||||||
throw new InvalidPostDataException('Invalid post data', $postData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$postData->getPost()->getAuthor()->getId()) {
|
if (!$postData->getPost()->getAuthor()->getId()) {
|
||||||
|
|
Loading…
Reference in a new issue