lilhermit/cakephp-plugin-toolkit

There is no license information available for the latest version (1.2.7) of this package.

Toolkit plugin for CakePHP-3

Installs: 6 963

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 1

Type:cakephp-plugin

1.2.7 2020-01-21 15:21 UTC

This package is auto-updated.

Last update: 2021-04-21 18:32:48 UTC


README

This plugin contains lots of useful content in one plugin

Installation

  • Add the plugin with the following command, replacing 1.* with dev-master if you want the bleeding edge:
composer require lilhermit/cakephp-plugin-toolkit:1.*
  • Load the plugin in your bootstrap.php
Plugin::load('LilHermit/Toolkit', ['bootstrap' => true]);

SluggableBehavior

Add the Behavior to any Table using $this->addBehavior('LilHermit/Toolkit.Sluggable'); in the initialize method

The Behavior takes the following config options

Option Type Default Description
field String title This is the field that will be the source of the slug
slug String slug This is the field that will be used for the destination of the slug
replacement String - (dash) What character will be used to replace spaces
lowercase Boolean false Should the slug be converted to lowercase
onCreate Boolean true Should the slug be updated on Create
onUpdate Boolean true Should the slug be updated on Update

Pass the options as an array like

$this->addBehavior('LilHermit/Toolkit.Sluggable', [
    'field' => 'name',
    'lowerCase' => true,
    'onUpdate' => false
]);