Skip to content

Commit

Permalink
Update NS to CamelCase (#1555)
Browse files Browse the repository at this point in the history
* Rename NS from tests to Tests

* Rename NS from behat to Behat

* fix missed renames

* Update atk4/core case

* Update atk4/data case

* Update atk4/schema case

* Update atk4/ui case

* other than major repos names

* Rename Atk4/Ui/demo to Atk4/Ui/Demos

* fix solved error
  • Loading branch information
mvorisek authored Dec 3, 2020
1 parent 34a6da6 commit 8014b6c
Show file tree
Hide file tree
Showing 354 changed files with 2,797 additions and 2,798 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Check Coding Style (only for CodingStyle)
if: matrix.type == 'CodingStyle'
run: |
if [ "$(find demos/ -name '*.php' -print0 | xargs -0 grep -L "namespace atk4\\\\ui\\\\demo;" | tee /dev/fd/2)" ]; then echo 'All demos/ files must have namespace declared' && (exit 1); fi
if [ "$(find demos/ -name '*.php' -print0 | xargs -0 grep -L "namespace Atk4\\\\Ui\\\\Demos;" | tee /dev/fd/2)" ]; then echo 'All demos/ files must have namespace declared' && (exit 1); fi
vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --diff-format=udiff --verbose --show-progress=dots
- name: Run Static Analysis (only for StaticAnalysis)
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Create "index.php" file with:
<?php
require_once __DIR__ . '/vendor/autoload.php';

$app = new \atk4\ui\App(); // That's your UI application
$app->initLayout([\atk4\ui\Layout\Centered::class]);
$app = new \Atk4\Ui\App(); // That's your UI application
$app->initLayout([\Atk4\Ui\Layout\Centered::class]);

$form = \atk4\ui\Form::addTo($app); // Yeah, that's a form!
$form = \Atk4\Ui\Form::addTo($app); // Yeah, that's a form!

$form->addField('email'); // adds field
$form->onSubmit(function ($form) {
Expand Down Expand Up @@ -88,11 +88,11 @@ To get most of ATK UI, use [ATK Data](https://github.com/atk4/data) to describe
[Crud](https://ui.agiletoolkit.org/demos/crud.php) is a fully-interractive component that supports pagination, reloading, conditions, data formatting, sorting, quick-search, ordering, custom actions and modals, but at the same time is very easy to use:

``` php
$app = new \atk4\ui\App('hello world');
$app->initLayout([\atk4\ui\Layout\Admin::class]);
$app->db = \atk4\data\Persistence::connect('mysql://user:pass@localhost/atk');
$app = new \Atk4\Ui\App('hello world');
$app->initLayout([\Atk4\Ui\Layout\Admin::class]);
$app->db = \Atk4\Data\Persistence::connect('mysql://user:pass@localhost/atk');

\atk4\ui\Crud::addTo($app)->setModel(new User($app->db));
\Atk4\Ui\Crud::addTo($app)->setModel(new User($app->db));
```

ATK Data allows you to set up relations between models:
Expand All @@ -112,7 +112,7 @@ class User extends Model {
Conventional Crud works only with a single model, but with add-on you can take advantage this relationship information: https://github.com/atk4/mastercrud

``` php
use \atk4\mastercrud\MasterCrud;
use \Atk4\Mastercrud\MasterCrud;

// set up $app here

Expand Down Expand Up @@ -149,21 +149,21 @@ Agile UI has some unique features:
One of the fundamental features of ATK is Callback - ability to dynamically generate a route then have JS part of the component invoke it. Thanks to this approach, code can be fluid, simple and readable:

``` php
$tabs = \atk4\ui\Tabs::addTo($app);
\atk4\ui\Message::addTo($tabs->addTab('Intro'), ['Other tabs are loaded dynamically!']);
$tabs = \Atk4\Ui\Tabs::addTo($app);
\Atk4\Ui\Message::addTo($tabs->addTab('Intro'), ['Other tabs are loaded dynamically!']);

$tabs->addTab('Users', function($p) use($app) {

// This tab is loaded dynamically, but also contains dynamic component
\atk4\ui\Crud::addTo($p)->setModel(new User($app->db));
\Atk4\Ui\Crud::addTo($p)->setModel(new User($app->db));
});

$tabs->addTab('Settings', function($p) use($app) {

// Second tab contains an AJAX form that stores itself back to DB.
$m = new Settings($app->db);
$m->load(2);
\atk4\ui\Form::addTo($p)->setModel($m);
\Atk4\Ui\Form::addTo($p)->setModel($m);
});
```

Expand All @@ -190,11 +190,11 @@ It's really easy to put together a complex Admin system. Add this code to a new
``` php
<?php

$app = new \atk4\ui\App('My App');
$app->initLayout([\atk4\ui\Layout\Admin::class]);
$app->db = \atk4\data\Persistence::connect('mysql://user:pass@localhost/yourdb');
$app = new \Atk4\Ui\App('My App');
$app->initLayout([\Atk4\Ui\Layout\Admin::class]);
$app->db = \Atk4\Data\Persistence::connect('mysql://user:pass@localhost/yourdb');

class User extends \atk4\data\Model {
class User extends \Atk4\Data\Model {
public $table = 'user';
function init(): void {
parent::init();
Expand All @@ -205,7 +205,7 @@ class User extends \atk4\data\Model {
}
}

\atk4\ui\Crud::addTo($app)->setModel(new User($app->db));
\Atk4\Ui\Crud::addTo($app)->setModel(new User($app->db));
```

The result is here:
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default:
paths:
features: '%paths.base%/tests-behat'
contexts:
- atk4\ui\behat\Context
- Atk4\Ui\Behat\Context
- Behat\MinkExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
},
"autoload": {
"psr-4": {
"atk4\\ui\\": "src/"
"Atk4\\Ui\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"atk4\\ui\\tests\\": "tests/",
"atk4\\ui\\behat\\": "tests-behat/bootstrap/"
"Atk4\\Ui\\Tests\\": "tests/",
"Atk4\\Ui\\Behat\\": "tests-behat/bootstrap/"
}
}
}
20 changes: 10 additions & 10 deletions demos/_demo-data/create-sqlite-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

use atk4\data\Model;
use Atk4\Data\Model;

require_once __DIR__ . '/../init-autoloader.php';

Expand All @@ -13,13 +13,13 @@
unlink($sqliteFile);
}

$persistence = new \atk4\data\Persistence\Sql('sqlite:' . $sqliteFile);
$persistence = new \Atk4\Data\Persistence\Sql('sqlite:' . $sqliteFile);

$model = new Model($persistence, 'client');
$model->addField('name', ['type' => 'string']);
$model->addField('addresses', ['type' => 'text']);
$model->addField('accounts', ['type' => 'text']);
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'name' => 'John', 'addresses' => null, 'accounts' => null],
['id' => 2, 'name' => 'Jane', 'addresses' => null, 'accounts' => null],
Expand All @@ -32,7 +32,7 @@
$model->addField('iso3', ['type' => 'string']); // should be CHAR(3) NOT NULL
$model->addField('numcode', ['type' => 'smallint']);
$model->addField('phonecode', ['type' => 'integer']);
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'iso' => 'AF', 'name' => 'AFGHANISTAN', 'nicename' => 'Afghanistan', 'iso3' => 'AFG', 'numcode' => 4, 'phonecode' => 93],
['id' => 2, 'iso' => 'AL', 'name' => 'ALBANIA', 'nicename' => 'Albania', 'iso3' => 'ALB', 'numcode' => 8, 'phonecode' => 355],
Expand Down Expand Up @@ -294,7 +294,7 @@
$model->addField('is_folder', ['type' => 'boolean']);
$model->addField('parent_folder_id', ['type' => 'bigint']);
// KEY `fk_file_file_idx` (`parent_folder_id`)
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'name' => 'phpunit.xml', 'type' => 'xml', 'is_folder' => 0, 'parent_folder_id' => null],
['id' => 2, 'name' => 'LICENSE', 'type' => '', 'is_folder' => 0, 'parent_folder_id' => null],
Expand Down Expand Up @@ -384,7 +384,7 @@
$model->addField('finish_time', ['type' => 'time']);
$model->addField('created', ['type' => 'datetime']);
$model->addField('updated', ['type' => 'datetime']);
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'project_name' => 'Agile DSQL', 'project_code' => 'at01', 'description' => 'DSQL is a composable SQL query builder. You can write multi-vendor queries in PHP profiting from better security, clean syntax and avoid human errors.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,\nGarden City\nUK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 1, 'project_budget' => 7000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 150, 'project_hours_reported' => 125, 'project_expenses_est' => 50, 'project_expenses' => 0, 'project_mgmt_cost_pct' => 0.1, 'project_qa_cost_pct' => 0.2, 'start_date' => '2016-01-26', 'finish_date' => '2016-06-23', 'finish_time' => '12:50:00', 'created' => '2017-04-06 10:34:34', 'updated' => '2017-04-06 10:35:04'],
['id' => 2, 'project_name' => 'Agile Core', 'project_code' => 'at02', 'description' => 'Collection of PHP Traits for designing object-oriented frameworks.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,\nGarden City\nUK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 1, 'project_budget' => 3000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 70, 'project_hours_reported' => 56, 'project_expenses_est' => 50, 'project_expenses' => 0, 'project_mgmt_cost_pct' => 0.1, 'project_qa_cost_pct' => 0.2, 'start_date' => '2016-04-27', 'finish_date' => '2016-05-21', 'finish_time' => '18:41:00', 'created' => '2017-04-06 10:21:50', 'updated' => '2017-04-06 10:35:04'],
Expand All @@ -394,7 +394,7 @@

$model = new Model($persistence, 'product_category');
$model->addField('name', ['type' => 'string']);
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'name' => 'Condiments and Gravies'],
['id' => 2, 'name' => 'Beverages'],
Expand All @@ -404,7 +404,7 @@
$model = new Model($persistence, 'product_sub_category');
$model->addField('name', ['type' => 'string']);
$model->addField('product_category_id', ['type' => 'bigint']);
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'name' => 'Gravie', 'product_category_id' => 1],
['id' => 2, 'name' => 'Spread', 'product_category_id' => 1],
Expand All @@ -422,7 +422,7 @@
$model->addField('brand', ['type' => 'string']);
$model->addField('product_category_id', ['type' => 'bigint']);
$model->addField('product_sub_category_id', ['type' => 'bigint']);
(new \atk4\schema\Migration($model))->dropIfExists()->create();
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
$model->import([
['id' => 1, 'name' => 'Mustard', 'brand' => 'Condiment Corp.', 'product_category_id' => 1, 'product_sub_category_id' => 2],
['id' => 2, 'name' => 'Ketchup', 'brand' => 'Condiment Corp.', 'product_category_id' => 1, 'product_sub_category_id' => 2],
Expand Down
12 changes: 6 additions & 6 deletions demos/_includes/Counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

/**
* Counter for certain demos file.
*/
class Counter extends \atk4\ui\Form\Control\Line
class Counter extends \Atk4\Ui\Form\Control\Line
{
public $content = 20; // default

protected function init(): void
{
parent::init();

$this->actionLeft = new \atk4\ui\Button(['icon' => 'minus']);
$this->action = new \atk4\ui\Button(['icon' => 'plus']);
$this->actionLeft = new \Atk4\Ui\Button(['icon' => 'minus']);
$this->action = new \Atk4\Ui\Button(['icon' => 'plus']);

$this->actionLeft->js('click', $this->jsInput()->val(new \atk4\ui\JsExpression('parseInt([])-1', [$this->jsInput()->val()])));
$this->action->js('click', $this->jsInput()->val(new \atk4\ui\JsExpression('parseInt([])+1', [$this->jsInput()->val()])));
$this->actionLeft->js('click', $this->jsInput()->val(new \Atk4\Ui\JsExpression('parseInt([])-1', [$this->jsInput()->val()])));
$this->action->js('click', $this->jsInput()->val(new \Atk4\Ui\JsExpression('parseInt([])+1', [$this->jsInput()->val()])));
}
}
10 changes: 5 additions & 5 deletions demos/_includes/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

class Demo extends \atk4\ui\Columns
class Demo extends \Atk4\Ui\Columns
{
public $left;
public $right;
Expand All @@ -26,7 +26,7 @@ protected function extractCodeFromClosure(\Closure $fx): string
{
$funcRefl = new \ReflectionFunction($fx);
if ($funcRefl->getEndLine() === $funcRefl->getStartLine()) {
throw new \atk4\ui\Exception('Closure body to extract must be on separate lines');
throw new \Atk4\Ui\Exception('Closure body to extract must be on separate lines');
}

$codeArr = array_slice(
Expand All @@ -49,7 +49,7 @@ public function setCodeAndCall(\Closure $fx, $lang = 'php')
$code = $this->extractCodeFromClosure($fx);

$this->highLightCode();
\atk4\ui\View::addTo(\atk4\ui\View::addTo($this->left, ['element' => 'pre']), ['element' => 'code'])->addClass($lang)->set($code);
\Atk4\Ui\View::addTo(\Atk4\Ui\View::addTo($this->left, ['element' => 'pre']), ['element' => 'code'])->addClass($lang)->set($code);

$fx($this->right);
}
Expand All @@ -59,7 +59,7 @@ public function highLightCode()
if (!self::$isInitialized) {
$this->getApp()->requireCss('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.16.2/styles/' . $this->highlightDefaultStyle . '.min.css');
$this->getApp()->requireJs('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.16.2/highlight.min.js');
$this->js(true, (new \atk4\ui\JsChain('hljs'))->initHighlighting());
$this->js(true, (new \Atk4\Ui\JsChain('hljs'))->initHighlighting());
self::$isInitialized = true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions demos/_includes/DemoActionsUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

class DemoActionsUtil
{
Expand Down Expand Up @@ -101,7 +101,7 @@ public static function setupDemoActions(CountryLock $country): void
return 'Be careful with this action.';
},
'callback' => function () {
throw new \atk4\ui\Exception('Told you, didn\'t I?');
throw new \Atk4\Ui\Exception('Told you, didn\'t I?');
},
]
);
Expand All @@ -111,7 +111,7 @@ public static function setupDemoActions(CountryLock $country): void
[
'caption' => 'User Confirmation',
'description' => 'Confirm the action using a ConfirmationExecutor',
'ui' => ['executor' => [\atk4\ui\UserAction\ConfirmationExecutor::class]],
'ui' => ['executor' => [\Atk4\Ui\UserAction\ConfirmationExecutor::class]],
'confirmation' => function ($a) {
return 'Are you sure you want to perform this action on: <b>' . $a->getModel()->getTitle() . ' (' . $a->getModel()->get('iso3') . ')</b>';
},
Expand Down
4 changes: 2 additions & 2 deletions demos/_includes/DemoInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

/**
* Invoice class for tutorial intro.
*/
class DemoInvoice extends \atk4\data\Model
class DemoInvoice extends \Atk4\Data\Model
{
public $dateFormat;

Expand Down
24 changes: 12 additions & 12 deletions demos/_includes/DemoLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

use atk4\core\Factory;
use Atk4\Core\Factory;

/**
* Setup file - do not test.
* Lookup that can not saved data.
*/
class DemoLookup extends \atk4\ui\Form\Control\Lookup
class DemoLookup extends \Atk4\Ui\Form\Control\Lookup
{
/**
* Add button for new record.
Expand All @@ -29,34 +29,34 @@ protected function initQuickNewRecord()

$buttonSeed = is_string($buttonSeed) ? ['content' => $buttonSeed] : $buttonSeed;

$defaultSeed = [\atk4\ui\Button::class, 'disabled' => ($this->disabled || $this->readonly)];
$defaultSeed = [\Atk4\Ui\Button::class, 'disabled' => ($this->disabled || $this->readonly)];

$this->action = Factory::factory(array_merge($defaultSeed, (array) $buttonSeed));

if ($this->form) {
$vp = \atk4\ui\VirtualPage::addTo($this->form);
$vp = \Atk4\Ui\VirtualPage::addTo($this->form);
} else {
$vp = \atk4\ui\VirtualPage::addTo($this->getOwner());
$vp = \Atk4\Ui\VirtualPage::addTo($this->getOwner());
}

$vp->set(function ($page) {
$form = \atk4\ui\Form::addTo($page);
$form = \Atk4\Ui\Form::addTo($page);

$model = clone $this->model;

$form->setModel($model->onlyFields($this->plus['fields'] ?? []));

$form->onSubmit(function (\atk4\ui\Form $form) {
$form->onSubmit(function (\Atk4\Ui\Form $form) {
// Prevent from saving
// $form->model->save();

$ret = [
new \atk4\ui\JsToast('Form submit!. Demo can not saved data.'),
(new \atk4\ui\Jquery('.atk-modal'))->modal('hide'),
new \Atk4\Ui\JsToast('Form submit!. Demo can not saved data.'),
(new \Atk4\Ui\Jquery('.atk-modal'))->modal('hide'),
];

if ($row = $this->renderRow($form->model)) {
$chain = new \atk4\ui\Jquery('#' . $this->name . '-ac');
$chain = new \Atk4\Ui\Jquery('#' . $this->name . '-ac');
$chain->dropdown('set value', $row['value'])->dropdown('set text', $row['title']);

$ret[] = $chain;
Expand All @@ -68,6 +68,6 @@ protected function initQuickNewRecord()

$caption = $this->plus['caption'] ?? 'Add New ' . $this->model->getModelCaption();

$this->action->js('click', new \atk4\ui\JsModal($caption, $vp));
$this->action->js('click', new \Atk4\Ui\JsModal($caption, $vp));
}
}
4 changes: 2 additions & 2 deletions demos/_includes/Flyers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace atk4\ui\demo;
namespace Atk4\Ui\Demos;

class Flyers extends \atk4\data\Model
class Flyers extends \Atk4\Data\Model
{
protected function init(): void
{
Expand Down
Loading

0 comments on commit 8014b6c

Please sign in to comment.