PReact PHP Ask Confirmation before Action: Ask confirmation before actions they are executed

Recommend this page to a friend!
  Info   View files Documentation   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-10-19 (19 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
preact 1.0.1The PHP License5PHP 5, Validation, Language
Description Author

This package can be used for asking confirmation before actions they are executed.

It provides an event handled and dispatcher class that can register event handling callback functions and invokes those functions when the event of that type is emitted.

The package also provides traits uses promises that can be used with classes that can check conditions to confirm that an action can be performed.

Picture of Ahmad Mustapha
Name: Ahmad Mustapha <contact>
Classes: 7 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 3x

Details

Preact

Performs action before-hand, confirms action execution.<br/> This program uses ReactPHP Promise for its promise implementation.

Installation

composer require ahmard/preact

Usage

  1. Event
  2. Preact

Event

An event system for simple event-driven programming.

use Preact\Event;

$event = new Event();

$event->on('user.created', function ($user){
    echo "User created: {$user['name']}";
});

$user = [
    'id' => 1,
    'name' => 'Admin'
];
$event->emit('user.created', [$user]);

You can use Preact\EventTrait trait directly in your class and have the functionality embedded in your code.

namespace App\User;

use Preact\EventTrait;

class User
{
    use EventTrait;
    
    public function create(array $userInfo)
    {
        //Save in DB
        $this->emit('created', [$userInfo]);
    }
}

$user = new User;

$user->on('created', function ($user){
    echo "User created: {$user['username']}\n";
});

$user->create([
    'username' => 'Admin',
    'email' => 'admin@test.local'
]);

Preact

Have confirmation before execution.

use React\Promise\PromisorInterface;
use Preact\PreactTrait;

class Animal
{
    use PreactTrait;
}

$animal = new Animal();

$animal->onPreact('can.create', function (PromisorInterface $promisor, $animalInfo){
    if($animalInfo['name'] == 'lion'){
        $promisor->resolve(true);
    }else{
        $promisor->reject(false);
    }
});

$animal->preact('can.create', ['lion'])
    ->then(function (){
        echo 'Animal creation allowed: lion';
    })
    ->otherwise(function (){
        echo 'Animal creation rejected: lion.\n';
    });

To see more use cases view examples.

Licence

Preact is MIT licenced.

  Files folder image Files  
File Role Description
Files folder imageexamples (3 files)
Files folder imagesrc (6 files)
Files folder imagetests (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  examples  
File Role Description
  Plain text file advance-preact.php Class Class source
  Plain text file simple-event.php Class Class source
  Plain text file simple-preact.php Class Class source

  Files folder image Files  /  src  
File Role Description
  Plain text file Event.php Class Class source
  Plain text file EventInterface.php Class Class source
  Plain text file EventTrait.php Class Class source
  Plain text file Preact.php Class Class source
  Plain text file PreactInterface.php Class Class source
  Plain text file PreactTrait.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file EventTest.php Class Class source
  Plain text file PreactTest.php Class Class source

 Version Control Unique User Downloads  
 100%
Total:0
This week:0

For more information send a message to info at phpclasses dot org.