2. Installation

2.1. Install the Bundle with Composer

In your project directory execute the following command to download the latest stable version:

1
composer require swp/content-list-bundle

This command requires you to have Composer installed globally. If it’s not installed globally, download the .phar file locally as explained in Composer documentation.

2.2. Enable the bundle and its dependencies

Enable the bundle by adding the following lines in the app/AppKernel.php file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new SWP\Bundle\ContentListBundle\SWPStorageBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            // ...
            new SWP\Bundle\ContentListBundle\SWPContentListBundle(),
        );

        // ...
    }

    // ...
}

Note

All dependencies will be installed automatically. You will just need to configure the respective bundles if needed.

2.3. Configure the bundle

  • YAML
    1
    2
    3
    4
    5
    6
    # app/config/config.yml
    swp_content_list:
        persistence:
            orm:
                # if true, ORM is enabled as a persistence backend
                enabled: true
    

Note

By default this bundle supports only Doctrine ORM as a persistence backend.

Note

If this bundle is used together with ContentBundle, configuration will be automatically pre-pended and enabled, so there is no need to configure it in your config file.

Configure Doctrine extensions which are used by this bundle:

1
2
3
4
5
6
7
# app/config/config.yml
stof_doctrine_extensions:
    orm:
        default:
            timestampable: true
            softdeleteable: true
            loggable: true

Using your custom list item content class:

  • YAML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    # app/config/config.yml
    swp_content_list:
        persistence:
            orm:
                # if true, ORM is enabled as a persistence backend
                enabled: true
                classes:
                    # ..
                    list_content:
                        model: Acme\MyBundle\Entity\Post
    

Note

Acme\MyBundle\Entity\Post must implement SWP\Component\ContentList\Model\ListContentInterface interface.

2.4. Update Database Schema

Run the following command:

1
$ php bin/console doctrine:schema:update --force

That’s it, the bundle is configured properly now!