PHP code example of bigfoot / content-bundle

1. Go to this page and download the library: Download bigfoot/content-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bigfoot / content-bundle example snippets


/* Widget/WidgetTest.php */

namespace Bigfoot\Bundle\ContentBundle\Widget;

use Bigfoot\Bundle\ContentBundle\Model\AbstractWidget;

class WidgetTest extends AbstractWidget
{

    /**
    * The name of your Widget
    * @return Slug
    */
    public function getName()
    {
        return 'widget_test';
    }

    /**
    * Label of your Widget
    * Displayed in the Dashboard section
    */
    public function getLabel()
    {
        return 'The Widget Test';
    }

    /**
    * Parameters of your Widget
    * These parameters have to be the parameters of the target Action Controller.
    */
    public function getDefaultParameters()
    {
        return array(
            'page_id' => 1
        );
    }

    /**
    * The target Route of your Widget
    * Route of the action controller
    */
    public function getRoute()
    {
        return 'content_page';
    }

    /**
    * Form type of your Widget
    * This is the specific form of your Widget to add your custom parameters
    * The parent have to be `bigfoot_bundle_contentbundle_widgettype`
    */
    public function getParametersType()
    {
        return 'Bigfoot\Bundle\ContentBundle\Form\WidgetTestType';
    }

}

/* Form/WidgetTestType.php */
namespace Bigfoot\Bundle\ContentBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class WidgetTestType extends AbstractType
{

    protected $container;

    /**
     * Constructor
     *
     * @param $container
     */
    public function __construct($container)
    {
        $this->container = $container;
    }

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('page_id');

    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Bigfoot\Bundle\ContentBundle\Entity\Widget'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'bigfoot_bundle_contentbundle_widgettesttype';
    }

    /**
    * This method has to return 'bigfoot_bundle_contentbundle_widgettype'
    * @return string
    */
    public function getParent()
    {
        return 'bigfoot_bundle_contentbundle_widgettype';
    }
}
 shell
php composer.phar update