dev-master
9999999-dev https://github.com/justinatack/deleteableDetects which database records can be deleted. Database records can be locked preventing deletion.
MIT
The Requires
by Justin Atack
cakephp
Detects which database records can be deleted. Database records can be locked preventing deletion.
Deleteable provides a way to flag a database record as deleteable or not deleteable. I created this CakePHP Behavior with the need to be able to set a tinyint(1) "delete" field in my database and set it to true or false (0 or 1). The plugin is flexible, you can set your own field name as long as it stores a boolean value. You can also specify the value on which the delete is blocked or not. So you could have the DeleteableBehavior work when it's true and not when false (default behavior is false). The reason you might want to do this when you name your Deletable field to say "locked" and hence you might want to have "locked" field set to 1 (or true), in other words "locked" records can not be deleted because they are "locked" = true., (*1)
The master branch has the following requirements:, (*2)
[Using Composer], (*3)
From your command line you can enter, (*4)
composer require justinatack/deleteable="*"
or add the plugin to your project's composer.json
- something like this:, (*5)
{ "require": { "justinatack/deleteable": "*" } }
Because this plugin has the type cakephp-plugin
set in it's own composer.json
, composer knows to install it inside your /Plugin
directory, rather than in the usual vendors file. It is recommended that you add /Plugin/Deleteable
to your .gitignore file. (Why? read this.), (*6)
Consider using "require-dev" if you only want to include Deleteable for your development environment., (*7)
[Manual], (*8)
Deleteable
app/Plugin/
[GIT Submodule], (*9)
In your app directory type:, (*10)
git submodule add git://github.com/justinatack/deleteable.git Plugin/Deleteable git submodule init git submodule update
[GIT Clone], (*11)
In your plugin directory type, (*12)
git clone git://github.com/justinatack/deleteable.git Deleteable
app/Config/bootstrap.php
file. If you are already using CakePlugin::loadAll();
, then the following is not necessary.:CakePlugin::load('Deleteable');
app/Model/AppModel.php
:class AppModel extends Model { public $actsAs = array( 'Deleteable.Deleteable', array( 'field' => 'delete', 'boolean' => false ) ); }
field
to your database field name that you want checked by the DeleteableBehavior. Default field is set to "delete". Make sure you create a TINYINT(1) field type in MySQL.If you have a problem with Deleteable please open an issue on GitHub., (*13)
If you'd like to contribute to Deleteable, check out the roadmap for any planned features. You can fork the project, add features, and send pull requests or open issues., (*14)
Deleteable has only one release so far. Please feel free to submit a pull request to add or improve the codebase., (*15)
The MIT License (MIT), (*16)
Copyright (c) 2015 Justin Atack, (*17)
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:, (*18)
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*19)
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., (*20)
Detects which database records can be deleted. Database records can be locked preventing deletion.
MIT
cakephp