Skip to content

Instantly share code, notes, and snippets.

@McGaiser
Created February 15, 2016 06:01
Show Gist options
  • Save McGaiser/eb452a730c417ff2abde to your computer and use it in GitHub Desktop.
Save McGaiser/eb452a730c417ff2abde to your computer and use it in GitHub Desktop.
Plugin Issue
//From /cam-website/config/bootstrap.php
Plugin::load('Incentives', ['bootstrap' => false, 'routes' => true]);
//From /cam-website/config/routes.php
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different URLs to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Plugin;
use Cake\Routing\Router;
Router::scope('/', function($routes) {
/**
* Here, we are connecting '/' (base path) to a controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, src/Template/Pages/home.ctp)...
*/
//$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
$routes->connect('/', ['controller' => 'Pages', 'action' => 'home'], ['_name' => 'home']);
$routes->connect('/members/', ['controller' => 'Members', 'action' => 'index'], ['_name' => 'members']);
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'home']);
$routes->connect('/initializeDb', ['controller' => 'Initialize', 'action' => 'initializeDb']);
/**
* Connect a route for the index action of any controller.
* And a more general catch all route for any action.
*
* The `fallbacks` method is a shortcut for
* `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);`
* `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);`
*
* You can remove these routes once you've connected the
* routes you want in your application.
*/
$routes->fallbacks();
});
/**
* Load all plugin routes. See the Plugin documentation on
* how to customize the loading of plugin routes.
*/
Plugin::routes();
//From /cam-website/plugins/Incentives/config/routes.php
<?php
use Cake\Routing\Router;
Router::plugin(
'Incentives',
['path' => '/incentives'],
function ($routes) {
$routes->fallbacks('DashedRoute');
}
);
//From /cam-website/plugins/Incentives/src/Controller/AppController.php
<?php
namespace Incentives\Controller;
use App\Controller\AppController as BaseController;
use Cake\Event\Event;
class AppController extends BaseController
{
public function beforeFilter(Event $event) {
parent::beforeFilter($event);
}
}
//From /cam-website/plugins/Incentives/src/Controller/TimeasController.php
<?php
// Incentives/src/Controller/TimeasController.php
namespace Incentives\Controller;
use Incentives\Controller\AppController;
use Cake\Event\Event;
use Cake\Network\Exception\NotFoundException;
class TimeasController extends AppController {
//public $helpers = ['Url'];
//public $components = ['Random'];
public function beforeFilter(Event $event) {
parent::beforeFilter($event);
//$this->Auth->allow([]);
}
public function index() {
$prestigeTypes = $this->Timeas->find('all');
$this->set(compact('prestigeTypes'));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment