Skip to content

Commit

Permalink
Quote pagepart
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Jul 8, 2019
1 parent 433facc commit a8cac92
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace {{ namespace }}\Entity\PageParts;

use {{ admin_type_full }};
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
* @ORM\Table(name="{{ table_name }}")
* @ORM\Entity
*/
class QuotePagePart extends AbstractPagePart
{
/**
* @var string
* @ORM\Column(name="title", type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private $title;

/**
* @var string
* @ORM\Column(name="text", type="text", nullable=true)
* @Assert\NotBlank()
*/
private $text;

public function setTitle(?string $title): self
{
$this->title = $title;

return $this;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setText(?string $text): self
{
$this->text = $text;

return $this;
}

public function getText(): ?string
{
return $this->text;
}

public function getDefaultView(): string
{
return 'pageparts/quote_pagepart/view.html.twig';
}

public function getDefaultAdminType(): string
{
return {{ admin_type_class }}::class;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace {{ namespace }}\Form\PageParts;

use {{ pagepart_class_full }};
use Kunstmaan\AdminBundle\Form\WysiwygType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;

class QuotePagePartAdminType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, [
'required' => true,
])
->add('text', WysiwygType::class, [
'required' => true,
])
;
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => {{ pagepart_class }}::class,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="quote-pp">
<p>{{ resource.title }}</p>
{{ resource.text|replace_url|raw }}
</div>

0 comments on commit a8cac92

Please sign in to comment.