xlabs/topsetbundle

Create manual rankings/top selection bundle

Installs: 323

Dependents: 1

Suggesters: 0

Security: 0

Type:symfony-bundle

1.0.7 2022-07-07 11:49 UTC

This package is auto-updated.

Last update: 2022-11-07 12:27:34 UTC


README

A redis driven result cache driver.

Installation

Install through composer:

php -d memory_limit=-1 composer.phar require xlabs/topsetbundle

In your AppKernel

public function registerbundles()
{
    return [
    	...
    	...
    	new XLabs\TopSetBundle\XLabsTopSetBundle(),
    ];
}

Routing

Append to main routing file:

# app/config/routing.yml
  
x_labs_top_set:
    resource: .
    type: xlabs_topset_routing

Configuration sample

Default values are shown below:

# app/config/config.yml
  
x_labs_top_set:
    # for firewall purposes; default is empty
    url_prefix: /members

Usage

You can access the top manager tool by using the following routing id:

xlabs_topset_manager

Check the manager main window; the plug icon will describe how to use it in the project.

Whenever you want an Entity to be reachable from the top manager, just include the following annotation in it:

namespace YourBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
...
use XLabs\TopSetBundle\Annotations as XLabsTopSet;

/**
 * @ORM\Entity
 * ...
 * @XLabsTopSet\Config(routeJSON="<your_routing_id>")
 */
class MyEntity
{
    ...
}

is the routing ID that will return all rows from that entity in JSON format, where each entry needs to be as follows:

    $entries = array();
    ... get results ...
    ... loop begin ...
        $entries[$row['id']] = array(
            'id' => $row['id'],
            'title' => $row['title'],
            'image' => $row['image']
        );
    ... loop end ...
    return json_encode($entries);

The search in the Top Entries Manager form will be performed on the "title" attribute.