Skip to content

Build admin dashboards based on sql aggregations over your blog posts.

License

Notifications You must be signed in to change notification settings

masteropen/goulmima-blog-bundle-

Repository files navigation

Prerequisites

This version of the bundle requires Symfony 4.3 or higher.

Installation

Step 1 : Download GoulmimaBlogBundle using composer

Open a command console, enter your project directory and execute:

$ composer require goulmima/blog-bundle

By default, this command will download the latest release version of the bundle (the recommended way).

Step 2 : Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project (if you are using symfony flex, this is done automatically):

// config/bundles.php

return [
    // ...
    Goulmima\BlogBundle\GoulmimaBlogBundle::class => ['all' => true],
];

step 3 : import routes

# config/routes.yaml

goulmima_blog:
    resource: '@GoulmimaBlogBundle/Controller/'
    type: annotation
    prefix: /some_prefix 

Usage

Step 1 : Make your posts entity

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Goulmima\BlogBundle\Entity\BlogPost as GoulmimaBlogPost;

/**
 * @ORM\Entity()
 */
class MyBlogPost extends GoulmimaBlogPost
{
    // you can add your own attributes ...
}

Step 2 : Update the database

$ php bin/console make:migration
$ php bin/console doctrine:migrations:migrate

Step 3 : Configure the bundle

# config/packages/goulmima_blog.yaml

goulmima_blog:
    post:
        class: 'App\Entity\MyBlogPost'

Step 4 : Implementation

You can access to GoulmimaBlogBundle services through :

  • Normal Symfony Dependency Injection.

Example from a controller :

namespace App\Controller;

use Goulmima\BlogBundle\Utils\Aggregation\AggregatorInterface;

/**
 * @param AggregatorInterface $aggregator
 * @return Response
 *
 * @Route("/default", name="default")
 */
public function index(AggregatorInterface $aggregator)
{
    // retrieve sum of registered posts based on given `goulmima_blog.post.class`
    $result = $aggregator->getSum();
}
  • Using directly the DefaultController of the bundle.

Doing like so, you can access to sum of registered posts, by going to /some_prefix or whatever the entry point you give to the bundle's routes without any additional configuration.

Configuration

goulmima_blog:
    db_driver: 'orm' # see 'mongodb', api entry point ...
    post:
        class: 'App\Entity\BlogPost'
        stats:
            # type     : amcharts4 full chart name using snake_case style
            # axis     : attribute name based on for axis
            # abscissa : used function to get y = myFunction(x) 
            - { type: 'date_based_data', axis: 'createdAt', abscissa: 'myFunction' }
            - { type: 'simple_column_chart', axis: 'createdAt', abscissa: 'myAnotherFunction' }

About

Build admin dashboards based on sql aggregations over your blog posts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published