Giter Site home page Giter Site logo

yii2-helpers's Introduction

yii2-helpers

Collection of handy helpers for Yii2 websites.

Installation

Composer

Add extension to your composer.json and update your dependencies as usual, e.g. by running composer update

{
    "require": {
        "nirvana-msu/yii2-helpers": "1.0.*@dev"
    }
}

##HtmlHelper

Inject arbitrary code into existing HTML structure, before or after a chosen opening/closing tag, e.g.:

$html = HtmlHelper::inject($htmlToInject, $originalHtml, 'head', HTMLHelper::TAG_OPENING, HTMLHelper::POS_AFTER);

Convert HTML to plain text:

$text = HtmlHelper::htmlToPlainText($html);

##MathHelper

Create a histogram with specified bins out of a given array:

  • $values array, e.g. [11, 12, 20, 25, 20.1, 33.5]
  • $edges array, e.g. [0, 10, 20, 30, 40]
  • returns array histogram, e.g. ['0-10' => [], '10-20' => [11,12], '20-30' => [20,25,20.1], '30-40' => [33.5]]
$histogram = MathHelper::histogram($values, $edges);

##RbacHelper

Create role with a given name and description and add it to RBAC system:

$role = RbacHelper::createRole($name, $description)

Create permission with a given name and description and add it to RBAC system, assigning permission to the role:

$permission = RbacHelper::createChildPermission($role, $name, $description);

Remove rule from RBAC system by name:

RbacHelper::removeRuleByName($rule->name);

Remove permission from RBAC system by name:

RbacHelper::removePermissionByName($name)

Remove role from RBAC system by name:

RbacHelper::removeRoleByName($name)

##License

Extension is released under MIT license.

yii2-helpers's People

Contributors

nirvana-msu avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.