2017 © Pedro Peláez
 

silverstripe-module commandpattern

The commandpattern module enables SilverStripe to decouple business logic from the MVC structure.

image

silverstripe/commandpattern

The commandpattern module enables SilverStripe to decouple business logic from the MVC structure.

  • Monday, April 25, 2016
  • by fb3rasp
  • Repository
  • 3 Watchers
  • 3 Stars
  • 546 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

This is an archived project and is no longer supported or updated by SilverStripe. Please do not file issues or pull-requests against this repo. If you wish to continue to develop this code yourself, we recommend you fork it or contact the maintainers directly (check latest commits for email addresses)., (*1)

SilverStripe Command Pattern Module

Maintainer Contact

  • Rainer Spittel (Nickname: fb3rasp) - rainer (at) silverstripe (dot) com

Requirements

  • SilverStripe V2.4

Documentation

The commandpattern module enables SilverStripe to decouple business logic from the MVC structure. Commands can be executed individually and have a reference to a calling controller., (*2)

To install this module, please clone this module, copy the commands folder into the root folder of the SilverStripe installation and run a dev/build, i.e.:, (*3)

http://localhost/silverstripe/dev/build, (*4)

The module consists of a Factory-class which will be used to request command actions. The factory class initiates the command and returns the command object to the calling method, i.e.:, (*5)

$command = CommandFactory::get_command('Test');, (*6)

This call will return initiate a TestCommand object and returns the instance. get_command also accepts two optional parameters:, (*7)

  • first parameter is a reference to the calling controller instance (@link Controller).
  • second parameter is a associated array for parameters.

Example

We want to create a command with takes two integer ('x' and 'y') values and when executing the command, it will return the result of x * y., (*8)

First create the command class in your project folder:, (*9)

<?php
class TestCommand extends ControllerCommand {

    public function execute() {
        $data = $this->getParameters();
        $x = $data['x'];
        $y = $data['y'];
        return (int)$x * (int) $y;
    }   
}

Installation Instructions

Add this module into your project folder (name mapping) and run a dev/build to generate the required database schema., (*10)

Usage Overview

Implements the command pattern for SilverStripe controllers. This enables the developers to move core business logic into a dedicated command class., (*11)

Ideal for de-coupling MVC from core business domain related logic., (*12)

Known issues

n/a, (*13)

The Versions

25/04 2016

dev-master

9999999-dev

The commandpattern module enables SilverStripe to decouple business logic from the MVC structure.

  Sources   Download

BSD-3-Clause

The Requires

 

by Rainer Spittel

silverstripe commandpattern

03/12 2012

3.0.x-dev

3.0.9999999.9999999-dev

The commandpattern module enables SilverStripe to decouple business logic from the MVC structure.

  Sources   Download

BSD-3-Clause

The Requires

 

by Rainer Spittel

silverstripe commandpattern

03/12 2012

3.0.0

3.0.0.0

The commandpattern module enables SilverStripe to decouple business logic from the MVC structure.

  Sources   Download

BSD-3-Clause

The Requires

 

by Rainer Spittel

silverstripe commandpattern