-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
162b225
commit 038ef75
Showing
34 changed files
with
559 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's Blog plugin for Sylius. | ||
* (c) Monsieur Biz <sylius@monsieurbiz.com> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusBlogPlugin\EventListener; | ||
|
||
use MonsieurBiz\SyliusBlogPlugin\Entity\ArticleInterface; | ||
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent; | ||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
#[AsEventListener(event: 'monsieurbiz_blog.article.initialize_update', method: 'initializeUpdateArticle')] | ||
#[AsEventListener(event: 'monsieurbiz_blog.case_study.initialize_update', method: 'initializeUpdateCaseStudy')] | ||
class ArticleListener | ||
{ | ||
public function initializeUpdateArticle(ResourceControllerEvent $event): void | ||
{ | ||
$article = $event->getSubject(); | ||
|
||
if (!$article instanceof ArticleInterface) { | ||
return; | ||
} | ||
|
||
if (ArticleInterface::BLOG_TYPE === $article->getType()) { | ||
return; | ||
} | ||
|
||
throw new NotFoundHttpException('The article has not been found'); | ||
} | ||
|
||
public function initializeUpdateCaseStudy(ResourceControllerEvent $event): void | ||
{ | ||
$article = $event->getSubject(); | ||
|
||
if (!$article instanceof ArticleInterface) { | ||
return; | ||
} | ||
|
||
if (ArticleInterface::CASE_STUDY_TYPE === $article->getType()) { | ||
return; | ||
} | ||
|
||
throw new NotFoundHttpException('The article has not been found'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's Blog plugin for Sylius. | ||
* (c) Monsieur Biz <sylius@monsieurbiz.com> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusBlogPlugin\Factory; | ||
|
||
use MonsieurBiz\SyliusBlogPlugin\Entity\ArticleInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
use Symfony\Component\DependencyInjection\Attribute\AsDecorator; | ||
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated; | ||
|
||
/** | ||
* @implements ArticleFactoryInterface<ArticleInterface> | ||
*/ | ||
#[AsDecorator(decorates: 'monsieurbiz_blog.factory.article')] | ||
final class ArticleFactory implements ArticleFactoryInterface | ||
{ | ||
/** | ||
* @param FactoryInterface<ArticleInterface> $originalArticleFactory | ||
*/ | ||
public function __construct( | ||
#[AutowireDecorated] | ||
private readonly FactoryInterface $originalArticleFactory | ||
) { | ||
} | ||
|
||
public function createNew(): ArticleInterface | ||
{ | ||
return $this->originalArticleFactory->createNew(); | ||
} | ||
|
||
public function createNewWithType(string $type): ArticleInterface | ||
{ | ||
$article = $this->createNew(); | ||
$article->setType($type); | ||
|
||
return $article; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's Blog plugin for Sylius. | ||
* (c) Monsieur Biz <sylius@monsieurbiz.com> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusBlogPlugin\Factory; | ||
|
||
use MonsieurBiz\SyliusBlogPlugin\Entity\ArticleInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
|
||
/** | ||
* @template T of ArticleInterface | ||
* | ||
* @extends FactoryInterface<T> | ||
*/ | ||
interface ArticleFactoryInterface extends FactoryInterface | ||
{ | ||
public function createNewWithType(string $type): ArticleInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz's Blog plugin for Sylius. | ||
* (c) Monsieur Biz <sylius@monsieurbiz.com> | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusBlogPlugin\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20240822185838 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE monsieurbiz_blog_article ADD thumbnailImage VARCHAR(255) DEFAULT NULL, ADD type VARCHAR(255) NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE monsieurbiz_blog_article DROP thumbnailImage, DROP type'); | ||
} | ||
} |
Oops, something went wrong.