Developed with love by KnpLabs Hire us for your project!
56

RulerZBundle

by K-Phoen

Symfony Bundle for RulerZ

RulerZBundle Build Status

This bundle integrates RulerZ into Symfony.

Installation

Require the bundle:

composer require 'kphoen/rulerz-bundle'

And declare it into your app/AppKernel.php file:

public function registerBundles()
{
    return array(
        // ...
        new KPhoen\RulerZBundle\KPhoenRulerZBundle(),
    );
}

Usage

This bundle registers a rulerz service which is an instance of RulerZ\RulerZ.

$rulerz = $this->container->get('rulerz');

$rulerz->filter(/* ... */);

See RulerZ's documentation
for more information.

Custom operators

Custom operators can be added
to RulerZ executors.
The bundle provide a way to register new operators directly from the container,
you just need to tag a service:

services:
    operator.array.like:
        class: RulerZ\Operator\ArrayExecutor\Like
        tags:
            - { name: rulerz.operator, target: native, operator: like }

In addition to the rulerz.operator tag, two other values are needed:
* target: the compilation target we want to register the operator for ;
* operator: the name that will be given to the operator in rules.

Important: Operators registered as classes must implement the __invoke
magic method as RulerZ expects custom operators to be defined as callable.

Validators

A rule validator is provided by the bundle. In its simplest form, it will only
validate the syntax of a given rule. Unknown variables or operators won't be
detected unless you define a whitelist of accepted values.

use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\RulerZ\Validator\Constraints as RulerZAssert;

class TaggingRule
{
    /**
     * @var string
     *
     * @Assert\NotBlank()
     * @RulerZAssert\ValidRule(
     *  allowed_variables={"title", "url", "isArchived", "isStared", "content", "language", "mimetype", "readingTime", "domainName"},
     *  allowed_operators={">", "<", ">=", "<=", "=", "is", "!=", "and", "not", "or"}
     * )
     */
    private $rule;
}

Configuration reference

# app/config/config.yml

rulerz:
    cache: "%kernel.cache_dir%/rulerz"
    debug: "%kernel.debug%"

    targets:
        native: false
        doctrine: false
        doctrine_dbal: false
        eloquent: false
        pomm: false
        solarium: false
        elasticsearch: false

The targets section allows you to enable only the compilation targets needed
by your application.

Licence

This bundle is under the MIT licence.

The MIT License (MIT)

Copyright (c) 2015 Kévin Gomez <contact@kevingomez.fr>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Update the bundle to work with RulerZ 1.0.x-dev
    By K-Phoen, 1 year ago
  • Release of new version 0.15.0
    By K-Phoen, 1 year ago
  • Remove useless config element from phpunit.xml.dist
    By K-Phoen, 1 year ago
  • Fix version constraint on mikey179/vfsStream
    By K-Phoen, 1 year ago
  • Add a few declare() and typehints
    By K-Phoen, 1 year ago
  • Explicitely declare the cache clear command
    By K-Phoen, 1 year ago
  • Drop symfony 2.8 support and require PHP >= 7.1
    By K-Phoen, 2 years ago
  • Merge pull request #18 from marclenderink/sf4-compatibility
    By web-flow, 2 years ago
  • Modified dependencies to allow SF4 components
    By , 2 years ago
  • Release of new version 0.14.1
    By Kévin Gomez, 2 years ago
  • Add a "release" target in the makefile
    By Kévin Gomez, 2 years ago
  • Merge pull request #16 from dzikismigol/patch-1
    By web-flow, 2 years ago
  • Add OOB support for doctrine_dbal target
    By web-flow, 2 years ago
  • Release of new version 0.14.0
    By Kévin Gomez, 2 years ago
  • Merge pull request #15 from K-Phoen/bridge
    By web-flow, 2 years ago
  • Simplify some tests
    By Kévin Gomez, 2 years ago
  • Update tests setup
    By Kévin Gomez, 2 years ago
  • Require kphoen/rulerz-bridge ^1.0
    By Kévin Gomez, 2 years ago
  • Fix a little style violation
    By Kévin Gomez, 2 years ago
  • Removed unused 'use' statements
    By Kévin Gomez, 2 years ago
  • Write quotes around parameters in the readme
    By Kévin Gomez, 2 years ago
  • Update travis config
    By Kévin Gomez, 2 years ago
  • Require at least symfony 2.8
    By Kévin Gomez, 2 years ago
  • Use the validator components from the bridge
    By Kévin Gomez, 2 years ago
  • Automatically enable the form extension
    By Kévin Gomez, 2 years ago
  • Also require rulerz-bridge
    By Kévin Gomez, 2 years ago
  • Release of new version 0.13.2
    By Kévin Gomez, 2 years ago
  • Fix tests
    By Kévin Gomez, 2 years ago
  • Do not test against hhvm anymore
    By Kévin Gomez, 2 years ago
  • Fix default value definition for the debug configuration option
    By Kévin Gomez, 2 years ago