Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
feat: Working on the new version
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmcarvalho committed Jun 26, 2020
1 parent 6618354 commit 21b619f
Show file tree
Hide file tree
Showing 75 changed files with 835 additions and 714 deletions.
6 changes: 3 additions & 3 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
6 changes: 3 additions & 3 deletions config/paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
8 changes: 4 additions & 4 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/

use Cake\Routing\Route\DashedRoute;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;

Router::plugin('DataTables', ['path' => '/data-tables'], function (RouteBuilder $builder) {
$builder->fallbacks(DashedRoute::class);
Expand Down
14 changes: 11 additions & 3 deletions src/Command/DataTablesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/

namespace DataTables\Command;
Expand Down Expand Up @@ -98,10 +98,12 @@ public function execute(Arguments $args, ConsoleIo $io): ?int {
foreach ($scanner->listUnskipped() as $item) {
$io->out('- ' . Inflector::camelize($item));
}

return static::CODE_SUCCESS;
}
if (!empty($this->_callback)) {
$io->warning(sprintf("You don't must use callback argument on bake configs."));

return static::CODE_SUCCESS;
}
$this->bakeConfig($args, $io);
Expand All @@ -114,17 +116,20 @@ public function execute(Arguments $args, ConsoleIo $io): ?int {
foreach ($validConfigs as $item) {
$io->out('- ' . Inflector::camelize($item));
}

return static::CODE_SUCCESS;
}
if (empty($this->_callback) || !in_array($this->_callback, $this->getValidCallbacks())) {
$io->warning(sprintf('You must choose a valid callback name like:'));
foreach ($this->getValidCallbacks() as $validCallback) {
$io->out(" - $validCallback");
}

return static::CODE_SUCCESS;
}
$this->bakeCallbackBody($args, $io);
}

return static::CODE_SUCCESS;
}

Expand Down Expand Up @@ -212,6 +217,7 @@ private function getValidCallbacks(): array {
$callbacks[$index] = str_replace(['callback_', '.twig'], '', $callback);
}
}

return $callbacks;
}

Expand All @@ -228,6 +234,7 @@ private function getValidConfigs(): array {
$configs[$index] = str_replace(['DataTables.php'], '', $callback);
}
}

return $configs;
}

Expand Down Expand Up @@ -261,6 +268,7 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
]);
$parser->removeOption('plugin');
$parser->removeOption('theme');

return $parser;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
2 changes: 0 additions & 2 deletions src/Controller/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace DataTables\Controller;

use DataTables\Controller\AppController;

/**
* Class AssetsController
* Created by allancarvalho in june 26, 2020
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Component/AssetsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/**
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Component/CssComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
10 changes: 5 additions & 5 deletions src/Controller/Component/DataTablesComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function initialize(array $config): void {
* original ConfigBundle Columns configuration on table render.
*
* @param string $dataTablesName
* @return \DataTables\Table\Columns
* @throws \ReflectionException
* @return \DataTables\Table\Columns
*/
public function getColumns(string $dataTablesName): Columns {
return $this->setEventAndGetObject($dataTablesName, 'Columns');
Expand All @@ -62,8 +62,8 @@ public function getColumns(string $dataTablesName): Columns {
* original ConfigBundle MainOption configuration on table render.
*
* @param string $dataTablesName
* @return \DataTables\Table\Option\MainOption
* @throws \ReflectionException
* @return \DataTables\Table\Option\MainOption
*/
public function getOptions(string $dataTablesName): MainOption {
return $this->setEventAndGetObject($dataTablesName, 'Options');
Expand All @@ -74,8 +74,8 @@ public function getOptions(string $dataTablesName): MainOption {
* original ConfigBundle QueryBaseState configuration on table render.
*
* @param string $dataTablesName
* @return \DataTables\Table\QueryBaseState
* @throws \ReflectionException
* @return \DataTables\Table\QueryBaseState
*/
public function getQuery(string $dataTablesName): QueryBaseState {
return $this->setEventAndGetObject($dataTablesName, 'Query');
Expand All @@ -86,8 +86,8 @@ public function getQuery(string $dataTablesName): QueryBaseState {
*
* @param string $dataTablesName
* @param string $objectName
* @return \DataTables\Table\QueryBaseState|\DataTables\Table\Option\MainOption|\DataTables\Table\Columns
* @throws \ReflectionException
* @return \DataTables\Table\QueryBaseState|\DataTables\Table\Option\MainOption|\DataTables\Table\Columns
*/
private function setEventAndGetObject(string $dataTablesName, string $objectName) {
$configBundle = $this->getConfigBundle($dataTablesName);
Expand All @@ -111,8 +111,8 @@ private function setEventAndGetObject(string $dataTablesName, string $objectName
* Get a ConfigBundle instance using its name or FQN.
*
* @param string $dataTables
* @return \DataTables\Table\ConfigBundle
* @throws \ReflectionException
* @return \DataTables\Table\ConfigBundle
*/
private function getConfigBundle(string $dataTables): ConfigBundle {
if (empty($this->_configBundles[$dataTables])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Component/JsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
12 changes: 6 additions & 6 deletions src/Controller/ProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/**
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down Expand Up @@ -54,8 +54,8 @@ public function beforeFilter(EventInterface $event) {
}

/**
* @return void
* @noinspection PhpUnused
* @return void
*/
public function getI18nTranslation() {
$json = [
Expand Down Expand Up @@ -94,10 +94,10 @@ public function getI18nTranslation() {
/**
* Index method
*
* @noinspection PhpUnused
* @param string $tablesCass
* @return \Cake\Http\Response|null|void Renders view
* @throws \ReflectionException
* @noinspection PhpUnused
* @return \Cake\Http\Response|null|void Renders view
*/
public function getTablesData(string $tablesCass) {
$configBundle = Builder::getInstance()->getConfigBundle(Inflector::camelize($tablesCass), $this->_cache);
Expand Down
6 changes: 3 additions & 3 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down
9 changes: 4 additions & 5 deletions src/StorageEngine/CacheStorageEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand All @@ -27,8 +27,6 @@ class CacheStorageEngine implements StorageEngineInterface {
private $_cacheConfigName = '_data_tables_config_bundles_';

/**
* CacheStorageEngine constructor.
*
* @param string|null $cacheConfigName
*/
public function __construct(?string $cacheConfigName = null) {
Expand Down Expand Up @@ -57,6 +55,7 @@ public function exists(string $key): bool {
*/
public function read(string $key): ?ConfigBundle {
$configBundle = Cache::read($key, '_data_tables_config_bundles_');

return ($configBundle instanceof ConfigBundle) ? $configBundle : null;
}

Expand Down
6 changes: 3 additions & 3 deletions src/StorageEngine/StorageEngineInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Copyright (c) Allan Carvalho 2020.
* Under Mit License
*
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
* link: https://github.com/wsssoftware/cakephp-data-renderer
* author: Allan Carvalho <allan.m.carvalho@outlook.com>
* license: MIT License https://github.com/wsssoftware/cakephp-datatables/blob/master/LICENSE
*/
declare(strict_types = 1);

Expand Down

0 comments on commit 21b619f

Please sign in to comment.