origammi / blocks-bundle
Symfony2 bundle for adding collection of different block to any entity.
Installs: 683
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 15
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.4
- doctrine/dbal: <2.5
- doctrine/doctrine-bundle: ~1.2
- doctrine/orm: ~2.2,>=2.2.3,<2.5
- infinite-networks/form-bundle: 1.0.*@alpha
- knplabs/doctrine-behaviors: ~1.0
- symfony/monolog-bundle: ~2.4
- trsteel/ckeditor-bundle: ~1.6
- vich/uploader-bundle: ~0.14
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ~2.2
- phpmd/phpmd: ~2.1
- phpunit/phpunit: ~4.3
- sebastian/phpcpd: ~2.0
- sensio/framework-extra-bundle: ~2.3
- squizlabs/php_codesniffer: ~2.0
- symfony/phpunit-bridge: 2.7.x-dev
- symfony/symfony: ~2.3
This package is not auto-updated.
Last update: 2020-01-10 15:16:21 UTC
README
Usage
Requirements
- PHP 5.4+
Register bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Origammi\Bundle\BlocksBundle\OrigammiBlocksBundle($this), new Infinite\FormBundle\InfiniteFormBundle, // ... ); }
Prepare entity
<?php namespace AppBundle\Entity; use Origammi\Bundle\BlocksBundle\Annotation as Origammi; use Origammi\Bundle\BlocksBundle\Entity\BlockCollection; class Post { // ... /** * @var BlockCollection * * @ORM\ManyToOne(targetEntity="Origammi\Bundle\BlocksBundle\Entity\BlockCollection", cascade={"remove", "persist"}) * @Origammi\BlockCollectionData( * allowed={"lead", "text", "quote"}, * required={"lead"} * ) */ private $blocks; /** * @var BlockCollection * * @ORM\ManyToOne(targetEntity="Origammi\Bundle\BlocksBundle\Entity\BlockCollection", cascade={"remove", "persist"}) * @Origammi\BlockCollectionData( * allowed={"text"}, * required={"text"} * ) */ private $sidebarBlocks; // ... /** * @return BlockCollection */ public function getBlocks() { return $this->blocks; } /** * @param BlockCollection $blocks * * @return $this */ public function setBlocks(BlockCollection $blocks) { $this->blocks = $blocks; return $this; } /** * @return BlockCollection */ public function getSidebarBlocks() { return $this->sidebarBlocks; } /** * @param BlockCollection $blocks * * @return $this */ public function setSidebarBlocks(BlockCollection $blocks) { $this->sidebarBlocks = $blocks; return $this; } }
Create form
<?php $form = $this ->createFormBuilder($post) ->add('blocks', 'origammi_blocks') ->add('sidebarBlocks', 'origammi_blocks') ->getForm();
Assets (optional)
In case you are using Admin LTE2, be sure to load assets in your layout.
<script type="text/javascript" src="{{ asset('bundles/origammiblocks/js/main.js') }}"></script>
'bundles/origammiblocks/css/admin-lte2.css'