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

Contributions-Symfony-RulerBundle

by hoaproject

The Hoa\Ruler Symfony2 bundle.

Hoa

Hoa is a modular, extensible and structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoathis\SymfonyRulerBundle

Integrates Hoa\Ruler in Symfony.

Installation

With Composer, to include this bundle into your
dependencies, you need to require
hoathis/symfony-ruler-bundle:

{
    "require": {
        "hoathis/symfony-ruler-bundle": "~0.0"
    }
}

And add RulerBundle to your AppKernel:

// app/AppKernel.php

class AppKernel extends Kernel
{
    // …

    public function registerBundles()
    {
        $bundles = array(
            // …
            new Hoathis\SymfonyRulerBundle\HoathisSymfonyRulerBundle(),
        );

        // …
    }
}

Quick usage

Ruler service

The RulerBundle defines a hoathis.ruler service that can be used as
described in Hoa\Ruler's documentation.

public function indexAction(Request $request)
{
    // 1. Write a rule.
    $ruler = $this->get('hoathis.ruler');
    $rule  = 'group in ["customer", "guest"] and points > 30';

    // 2. Create a context.
    $context           = $ruler->getNewContext();
    $context['group']  = 'customer';
    $context['points'] = function () {
        return 42;
    };

    // 3. Assert!
    var_dump(
        $ruler->assert($rule, $context) // bool(true)
    );
}

Profiler

When the debug mode is enabled, all assertions are logged and displayed in the
web profiler:

profiler toolbar
profiler panel

Configuration reference

hoathis_symfony_ruler:
    debug:  %kernel.debug%

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see
LICENSE.

New BSD License



Copyright © 2007-2015, Hoa community.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Hoa nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
hoathis_symfony_ruler:
debug: false
  • Prepare 0.16.12.05.
    By , 2 years ago
  • Updated dependency version
    By web-flow, 2 years ago
  • Update Hoa's logo.
    By Hywan, 3 years ago
  • Update Hoa's logo
    By K-Phoen, 3 years ago
  • Invalid Yaml definitions in Symfony 3.0
    By K-Phoen, 3 years ago
  • Fix configuration root
    By K-Phoen, 4 years ago
  • Provide a factory method in Ruler to create a new context
    By K-Phoen, 4 years ago
  • The bundle is Symfony 3.0 ready
    By K-Phoen, 4 years ago
  • Updated the bundle's namespace to "Hoathis\SymfonyRulerBundle"
    By K-Phoen, 4 years ago
  • Update copyright
    By K-Phoen, 4 years ago
  • Fix style in README
    By K-Phoen, 4 years ago
  • Remove useless spaces in the composer.json file
    By K-Phoen, 4 years ago
  • Use the short array syntax
    By K-Phoen, 4 years ago
  • Added @copyrights and @license annotations
    By K-Phoen, 4 years ago
  • Add license blocks
    By K-Phoen, 4 years ago
  • Add LICENSE file
    By K-Phoen, 4 years ago
  • Clean a bit the composer.json file
    By K-Phoen, 4 years ago
  • Fix link to the documentation
    By K-Phoen, 4 years ago
  • Add .gitattributes
    By K-Phoen, 4 years ago
  • Add screenshots of the toolbar in the readme
    By K-Phoen, 4 years ago
  • Start to fill the readme
    By K-Phoen, 4 years ago
  • Only use the logged ruler when debug is enabled
    By K-Phoen, 4 years ago
  • Add composer.json
    By K-Phoen, 4 years ago
  • First draft of a WebDebugToolbar integration
    By K-Phoen, 4 years ago
  • Provide a hoathis.ruler service
    By K-Phoen, 4 years ago
  • First commit.
    By Hywan, 4 years ago