Last active
December 19, 2015 00:09
-
-
Save dominikkukacka/5866741 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
namespace XXXX\MediaToolBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Entity | |
* @ORM\Table(name="faqs") | |
*/ | |
class Faq{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="bigint") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $question; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $answer; | |
/** | |
* @ORM\ManyToOne(targetEntity="FaqCategory", inversedBy="faqs") | |
* @ORM\JoinColumn(onDelete="SET NULL") | |
*/ | |
private $category; | |
/** | |
* @ORM\Column(type="datetime", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | |
*/ | |
protected $timeCreated; | |
public function __toString() | |
{ | |
return $this->getQuestion(); | |
} |
This file contains hidden or 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
<?php | |
namespace XXXX\MediaToolBundle\Admin; | |
use Sonata\AdminBundle\Admin\Admin; | |
use Sonata\AdminBundle\Form\FormMapper; | |
use Sonata\AdminBundle\Datagrid\DatagridMapper; | |
use Sonata\AdminBundle\Datagrid\ListMapper; | |
use Sonata\AdminBundle\Show\ShowMapper; | |
use Sonata\AdminBundle\Route\RouteCollection; | |
use Knp\Menu\ItemInterface as MenuItemInterface; | |
use XXXX\MediaToolBundle\Entity\Faq; | |
use XXXX\MediaToolBundle\Entity\FaqCategory; | |
class FaqAdmin extends Admin | |
{ | |
/** | |
* @param \Sonata\AdminBundle\Show\ShowMapper $showMapper | |
* | |
* @return void | |
*/ | |
protected function configureShowField(ShowMapper $showMapper) | |
{ | |
$showMapper | |
->add('question') | |
->add('answer') | |
->add('category', 'sonata_type_model') | |
; | |
} | |
/** | |
* @param \Sonata\AdminBundle\Form\FormMapper $formMapper | |
* | |
* @return void | |
*/ | |
protected function configureFormFields(FormMapper $formMapper) | |
{ | |
$formMapper | |
->with('Allgemein') | |
->add('question') | |
->add('answer') | |
->end() | |
->with('FAQs') | |
->add('faqs', 'sonata_type_model', array('expanded' => true)) | |
->end() | |
; | |
} | |
/** | |
* @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper | |
* | |
* @return void | |
*/ | |
protected function configureListFields(ListMapper $listMapper) | |
{ | |
$listMapper | |
->addIdentifier('id') | |
->add('question') | |
->add('answer') | |
->add('category') | |
->add('_action', 'actions', array( | |
'actions' => array( | |
'view' => array(), | |
'edit' => array(), | |
'delete' => array(), | |
) | |
)) | |
; | |
} | |
/** | |
* @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper | |
* | |
* @return void | |
*/ | |
protected function configureDatagridFilters(DatagridMapper $datagridMapper) | |
{ | |
$datagridMapper | |
->add('question') | |
->add('answer') | |
; | |
} | |
} |
This file contains hidden or 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
<?php | |
namespace XXXX\MediaToolBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Entity | |
* @ORM\Table(name="faqcategories") | |
*/ | |
class FaqCategory{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="bigint") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $name; | |
/** | |
* @ORM\Column(type="string") | |
*/ | |
protected $icon; | |
/** | |
* @ORM\OneToMany(targetEntity="Faq", mappedBy="category") | |
* @ORM\JoinColumn(nullable=false) | |
*/ | |
private $faqs; | |
/** | |
* @ORM\Column(type="datetime", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | |
*/ | |
protected $timeCreated; | |
public function __toString() | |
{ | |
return (string)$this->getName(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment