Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zunnu committed Feb 14, 2021
1 parent df2b564 commit c593575
Show file tree
Hide file tree
Showing 27 changed files with 54,225 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/composer.lock
/phpunit.xml
/vendor
config/Migrations/schema-dump-default.lock
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# CakePHP-AssociationDebugger
# AssociationsDebugger plugin for CakePHP

## Installation

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).

The recommended way to install composer packages is:

```
composer require your-name-here/AssociationsDebugger
```
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "zunnu/AssociationsDebugger",
"description": "AssociationsDebugger plugin for CakePHP",
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"cakephp/cakephp": "^3.5"
},
"require-dev": {
"phpunit/phpunit": "^5.7.14|^6.0"
},
"autoload": {
"psr-4": {
"AssociationsDebugger\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"AssociationsDebugger\\Test\\": "tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
}
}
6 changes: 6 additions & 0 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
use Cake\Core\Configure;

if (Configure::read('debug')) {
Configure::write('DebugKit.panels', ['AssociationsDebugger.Associations']);
}
18 changes: 18 additions & 0 deletions config/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;

Router::plugin(
'AssociationsDebugger',
['path' => '/associations-debugger'],
function (RouteBuilder $routes) {
$routes->connect('/', ['controller' => 'Associations', 'action' => 'index']);
$routes->connect('/:action/*', ['controller' => 'Associations']);
// $routes->scope('/', function ($routes) {
// $routes->connect('/:action/*', ['controller' => 'Associations']);
// });

$routes->fallbacks(DashedRoute::class);
}
);
35 changes: 35 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>

<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="AssociationsDebugger">
<directory>tests/TestCase/</directory>
</testsuite>
</testsuites>

<!-- Setup a listener for fixtures -->
<listeners>
<listener class="Cake\TestSuite\Fixture\FixtureInjector">
<arguments>
<object class="Cake\TestSuite\Fixture\FixtureManager"/>
</arguments>
</listener>
</listeners>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

</phpunit>
9 changes: 9 additions & 0 deletions src/Controller/AppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AssociationsDebugger\Controller;

use App\Controller\AppController as BaseController;

class AppController extends BaseController
{
}
51 changes: 51 additions & 0 deletions src/Controller/AssociationsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
namespace AssociationsDebugger\Controller;

use AssociationsDebugger\Controller\AppController;
use Cake\Log\Log;
use AssociationsDebugger\Gate;

/**
* EnforcerGroupPermissions Controller
*
* @property \Enforcer\Model\Table\EnforcerGroupPermissionsTable $EnforcerGroupPermissions
*
* @method \Enforcer\Model\Entity\EnforcerGroupPermission[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class AssociationsController extends AppController
{
public function initialize() {
parent::initialize();
$this->Gate = new Gate();
}

public function index() {
$this->viewBuilder()->setLayout(false);
$conditions = [];

// SEARCH
if ($this->request->is('get')) {
if(!empty($this->request->getQueryParams())) {
$data = $this->request->getQueryParams();

if(!empty($data['plugins']) && $data['plugins'] !== 'undefined') {
$plugins = explode(',', $data['plugins']);
$conditions['plugins'] = $plugins;
}

if(!empty($data['associationTypes']) && $data['associationTypes'] !== 'undefined') {
$associationTypes = explode(',', $data['associationTypes']);
$conditions['associationTypes'] = $associationTypes;
}
}
}

$this->set('associationCollections', $this->Gate->associations($conditions)->array());
$this->set('associationTypes', $this->Gate->getAssociationTypes());
$this->set('activePlugins', $this->Gate->getPlugins());

if($this->request->is('ajax')) {
$this->render('Element/associationTree');
}
}
}
Loading

0 comments on commit c593575

Please sign in to comment.