Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

cakebaker/controller-list-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

ControllerList component for CakePHP

Purpose

A simple component for CakePHP 2.x which returns a list of controllers and the corresponding action names.

Requirements

Requires at least PHP 5.3.

Installation

Copy the file app/Controller/Component/ControllerListComponent.php to the Controller/Component folder of your application.

Usage

First, you have to add the component to the $components array of your controller(s):

public $components = array('ControllerList');

Then you can use the component in your action(s) with: $this->ControllerList->getList(). You can also specify the controllers which should be excluded from the returned list: $this->ControllerList->getList(array('UsersController')). Please note that without this parameter, the PagesController is automatically excluded.

The structure of the returned array is like:

<?php
array(
  'ExampleController' => array(
    'name' => 'Example',
    'displayName' => 'Example',
    'actions' => array(
      (int) 0 => 'index',
      (int) 1 => 'show'
    )
  ),
  'VendorExampleController' => array(
    'name' => 'VendorExample',
    'displayName' => 'Vendor Example',
    'actions' => array(
      (int) 0 => 'index',
      (int) 1 => 'callback',
      (int) 2 => 'api'
    )
  )
)

Configuration

The component provides two configuration options.

The first option, includePlugins, determines whether controllers in plugins are listed. By default, those controllers are ignored.

public $components = array('ControllerList' => array('includePlugins' => true));

The second option, parentControllers, allows you to specify parent controllers other than AppController.

public $components = array('ControllerList' => array('parentControllers' => array('ParentController')));

Changes

v2.0.2 (2016-01-11)

  • Added the configuration option includePlugins. Thanks to Oscar!

v2.0.1 (2015-11-18)

  • Added the configuration option parentControllers. Thanks to leodisarli!

v2.0.0 (2012-07-30)

  • Added parameter $controllersToExclude to the getList() method
  • Changed the structure of the returned array by including the keys name, displayName and actions. Thanks to Charles A. Beasley!

v1.0.0 (2012-01-29)

2010-06-29

  • Initial release

Contact

If you have questions or feedback, feel free to contact me via Twitter (@dhofstet) or by email ([email protected]).

License

The ControllerList component is licensed under the MIT license.

About

A simple CakePHP component which returns a list of controllers

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages