2017 © Pedro Peláez
 

cakephp-plugin optimistic-lock

Optimistic Lock plugin for CakePHP3

image

kaihiro/optimistic-lock

Optimistic Lock plugin for CakePHP3

  • Thursday, April 13, 2017
  • by kaihiro
  • Repository
  • 3 Watchers
  • 1 Stars
  • 481 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 12 % Grown

The README.md

OptimisticLock plugin for CakePHP3

Installation

You can install this plugin into your CakePHP application using composer., (*1)

The recommended way to install composer packages is:, (*2)

composer require kaihiro/optimistic-lock

Usage

Table

<?php
use OptimisticLock\Model\OptimisticLockTableTrait;
class PostsTable extends Table
{
    // Add the trait to your table
    use OptimisticLockTableTrait;

    public function initialize(array $config)
    {
        // Add the behaviour to your table
        $this->addBehavior('OptimisticLock.OptimisticLock');
    }
}

FormHelper

<?php
use OptimisticLock\View\Helper\OptimisticLockFormTrait;
class AppFormHelper extends FormHelper
{
    // Add the trait to your FormHelper
    use OptimisticLockFormTrait;
}

Controller

<?php
use OptimisticLock\Exception\OptimisticLockException;
class PostsController extends AppController
{
    public function edit($id = null)
    {
        $post = $this->Posts->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            try {
                $post = $this->Posts->patchEntity($post, $this->request->data);
                if ($this-> Posts->save($post)) {
                    $this->Flash->success(__('The post result has been saved.'));

                    return $this->redirect(['action' => 'index']);
                } else {
                    $this->Flash->error(__('The post could not be saved. Please, try again.'));
                }

            // You can handle optimistic lock by catching OptimisticLockException.
            } catch (OptimisticLockException $e) {
                $this->Flash->error(__('optimistic lock error.'));
            }
        }
        $this->set(compact('post'));
        $this->set('_serialize', ['post']);
    }

The Versions

13/04 2017

dev-master

9999999-dev

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires

13/04 2017

1.0.1

1.0.1.0

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires

14/12 2016

1.0.0

1.0.0.0

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires

14/12 2016

dev-bugfix_exclusion_control

dev-bugfix_exclusion_control

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires

07/12 2016

0.0.4

0.0.4.0

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires

06/12 2016

0.0.3

0.0.3.0

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires

06/12 2016

0.0.2

0.0.2.0

Optimistic Lock plugin for CakePHP3

  Sources   Download

The Requires

 

The Development Requires