-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
8 changed files
with
113 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240103154351 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add context to QOTD'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE qotd ADD context TEXT'); | ||
$this->addSql('UPDATE qotd SET context = \'\''); | ||
$this->addSql('ALTER TABLE qotd ALTER context SET NOT NULL'); | ||
$this->addSql('ALTER TABLE qotd ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE'); | ||
$this->addSql('COMMENT ON COLUMN qotd.updated_at IS \'(DC2Type:datetime_immutable)\''); | ||
$this->addSql('UPDATE qotd SET updated_at = NOW()'); | ||
$this->addSql('ALTER TABLE qotd ALTER updated_at SET NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE qotd DROP context'); | ||
$this->addSql('ALTER TABLE qotd DROP updated_at'); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace App\Form\Extension; | ||
|
||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
class TextTypeExtension extends AbstractTypeExtension | ||
{ | ||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'empty_data' => '', | ||
]); | ||
} | ||
|
||
public static function getExtendedTypes(): iterable | ||
{ | ||
yield TextType::class; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace App\Form\Type; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
class QotdType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('context', TextareaType::class, [ | ||
'required' => false, | ||
]) | ||
; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
{% macro message(qotd) %} | ||
{% cache "qotd-message-#{qotd.message}" %} | ||
{% cache "qotd-message-#{qotd.id}-#{qotd.updatedAt.format('c')}" %} | ||
{# we use |replace because it better like that! #} | ||
{% if qotd.context %} | ||
<blockquote class="text-body-secondary"> | ||
{{ qotd.context|replace_emoji|replace_username|replace({'\n': '\n\n'})|markdown_to_html }} | ||
</blockquote> | ||
{% endif %} | ||
{{ qotd.message|replace_emoji|replace_username|replace({'\n': '\n\n'})|markdown_to_html }} | ||
{% endcache %} | ||
{% endmacro %} |
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