2017 © Pedro Peláez
 

cakephp-plugin cake-factory

Cake is a factory for the Cake Toolkit (CTK) which provides configurable objects for the core helpers in CakePHP

image

jameswatts/cake-factory

Cake is a factory for the Cake Toolkit (CTK) which provides configurable objects for the core helpers in CakePHP

  • Saturday, October 26, 2013
  • by jameswatts
  • Repository
  • 2 Watchers
  • 9 Stars
  • 1,391 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Cake Factory

Cake is a CakePHP plugin which provides an additional factory for the Cake Toolkit (CTK), adding configurable objects for the core Html and Form helpers available with the framework., (*1)

The inclusion of an object-oriented interface for the core helpers allows for a more sophisticated usage, such as adding child nodes and binding events, as well as improving the overall level of abstraction and separation of concerns in the View layer., (*2)

Requirements

  • CakePHP 2+
  • PHP 5.3+
  • Cake Toolkit (https://github.com/jameswatts/cake-toolkit)

Installation

To use the plugin simply include it in your application's "app/Plugin" directory, and load it in the "app/Config/bootstrap.php" file., (*3)

CakePlugin::load('CakeFactory');

The above code is not required if you're already using CakePlugin::loadAll() to load all plugins., (*4)

Implementation

Once the plugin is available it's ready to use in your CTK Views, or with the Factory helper included with the Cake Toolkit. To include the Cake factory in a View just add the factory to your $factories collection, for example:, (*5)

public $factories = array('CakeFactory.Cake');

With the factory now available you can call it in your View, and build your application using the Html and Form helpers via an object-oriented interface., (*6)

Here's a simple example of creating a link from the Html helper:, (*7)

$this->Cake->Link(array(
    'title' => __('Read more'),
    'url' => array(
        'controller' => 'Posts',
        'action' => 'view',
        $postId
    )
)); 

Another example, creating a form with an input from the Form helper, with the additional binding of an event to the input element:, (*8)

// create a CakePHP form
$form = $this->Cake->Form(array(
    'model' => 'Example',
    'options' => array(
        'action' => 'add'
    )
));
    // create a CakePHP input
    $input = $this->Cake->Input(array(
        'field' => 'Example.column',
        'type' => 'text'
    ));
    // bind an event to the input
    $input->bind('keyup', $this->Js->Alert(array(
        'code' => $this->Js->Element(array('node' => $input))->getValue()
    )));
// add the input to the form
$form->add($input);
// add the form to the view
$this->add($form);

Support

For support, bugs and feature requests, please use the issues section of this repository., (*9)

Licence

Copyright 2013 James Watts (CakeDC). All rights reserved., (*10)

Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file., (*11)

Acknowledgements

Thanks to Larry Masters and everyone who has contributed to CakePHP, helping make this framework what it is today., (*12)

The Versions

26/10 2013

dev-master

9999999-dev https://github.com/jameswatts/cake-factory

Cake is a factory for the Cake Toolkit (CTK) which provides configurable objects for the core helpers in CakePHP

  Sources   Download

MIT

The Requires

 

cakephp factory toolkit cake ctk

26/10 2013

dev-beta

dev-beta https://github.com/jameswatts/cake-factory

Cake is a factory for the Cake Toolkit (CTK) which provides configurable objects for the core helpers in CakePHP

  Sources   Download

MIT

The Requires

 

cakephp factory toolkit cake ctk