Skip to content

Commit

Permalink
Namespace fix, getApp fix [for 2.4] (#39)
Browse files Browse the repository at this point in the history
* Namespace fix, getApp fix

* Update unit-tests.yml
  • Loading branch information
DarkSide666 authored Dec 5, 2020
1 parent 6c17ce5 commit bccc12d
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ jobs:

- name: Configure PHP
run: |
if [ -z "$LOG_COVERAGE" ]; then rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ; fi
if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi
php --version
# trick composer that this is a "atk4/core:develop" dependency to install atk4/data
#- name: Rename HEAD to develop for Composer
# run: git switch -C develop HEAD

- name: Setup cache 1/2
id: composer-cache
run: |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
},
"autoload": {
"psr-4": {
"atk4\\mastercrud\\": "src/"
"Atk4\\MasterCrud\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"atk4\\mastercrud\\tests\\": "tests/"
"Atk4\\MasterCrud\\Tests\\": "tests/"
}
}
}
6 changes: 4 additions & 2 deletions demos/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

declare(strict_types=1);

namespace Atk4\MasterCrud\Demo;

include 'init.php';

use atk4\mastercrud\MasterCRUD;
use atk4\ui\Crud;
use Atk4\MasterCrud\MasterCRUD;
use Atk4\Ui\Crud;

$app->cdn['atk'] = '../public';
$mc = $app->add([
Expand Down
2 changes: 2 additions & 0 deletions demos/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

declare(strict_types=1);

namespace Atk4\MasterDrud\Demo;

// only PostgreSQL db is provided, if you port it to MySQL please create PR for this
// nice add-on.
12 changes: 7 additions & 5 deletions demos/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

declare(strict_types=1);

namespace Atk4\MasterCrud\Demo;

require '../vendor/autoload.php';
require 'db.php';

use atk4\data\Model;
use atk4\data\Persistence;
use atk4\ui\App;
use atk4\ui\Layout;
use atk4\ui\Message;
use Atk4\Data\Model;
use Atk4\Data\Persistence;
use Atk4\Ui\App;
use Atk4\Ui\Layout;
use Atk4\Ui\Message;

$app = new App('MasterCRUD Demo');
$app->initLayout([Layout\Centered::class]);
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\AtkPhpunit\ResultPrinter">
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="Atk4\Core\AtkPhpunit\ResultPrinter">
<php>
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="" />
Expand Down
34 changes: 17 additions & 17 deletions src/MasterCRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

declare(strict_types=1);

namespace atk4\mastercrud;

use atk4\data\Model;
use atk4\ui\Breadcrumb;
use atk4\ui\CardTable;
use atk4\ui\Crud;
use atk4\ui\Exception;
use atk4\ui\JsModal;
use atk4\ui\Table;
use atk4\ui\Tabs;
use atk4\ui\View;
use atk4\ui\VirtualPage;
namespace Atk4\MasterCrud;

use Atk4\Data\Model;
use Atk4\Ui\Breadcrumb;
use Atk4\Ui\CardTable;
use Atk4\Ui\Crud;
use Atk4\Ui\Exception;
use Atk4\Ui\JsModal;
use Atk4\Ui\Table;
use Atk4\Ui\Tabs;
use Atk4\Ui\View;
use Atk4\Ui\VirtualPage;

class MasterCRUD extends View
{
Expand Down Expand Up @@ -100,15 +100,15 @@ public function setModel(Model $m, array $defs = null): Model
$this->crumb->addCrumb($this->getCaption($m), $this->url());

// extract path
$this->path = explode($this->pathDelimiter, $this->app->stickyGet('path') ?? '');
$this->path = explode($this->pathDelimiter, $this->gteApp()->stickyGet('path') ?? '');
if ($this->path[0] === '') {
unset($this->path[0]);
}

$defs = $this->traverseModel($this->path, $defs ?? []);

$arg_name = $this->model->table . '_id';
$arg_val = $this->app->stickyGet($arg_name);
$arg_val = $this->getApp()->stickyGet($arg_name);
if ($arg_val && $this->model->tryLoad($arg_val)->loaded()) {
// initialize Tabs
$this->initTabs($defs);
Expand Down Expand Up @@ -150,7 +150,7 @@ public function initTabs(array $defs, View $view = null)
}

$this->tabs = $view->add($this->getTabsSeed($defs));
$this->app->stickyGet($this->model->table . '_id');
$this->getApp()->stickyGet($this->model->table . '_id');

$this->crumb->addCrumb($this->getTitle($this->model), $this->tabs->url());

Expand Down Expand Up @@ -184,7 +184,7 @@ public function initTabs(array $defs, View $view = null)
// $sub_crud->addDecorator($m->title_field, [Table\Column\Link::class, [$t => false, 'path' => $this->getPath($ref)], [$m->table . '_id' => 'id']]);

// Creating url template in order to produce proper url.
$sub_crud->addDecorator($m->title_field, [Table\Column\Link::class, 'url' => $this->app->url(['path' => $this->getPath($ref)]) . '&' . $m->table . '_id=' . '{$id}']);
$sub_crud->addDecorator($m->title_field, [Table\Column\Link::class, 'url' => $this->getApp()->url(['path' => $this->getPath($ref)]) . '&' . $m->table . '_id=' . '{$id}']);
}

$this->addActions($sub_crud, $subdef);
Expand Down Expand Up @@ -370,7 +370,7 @@ public function traverseModel(array $path, array $defs): array

// argument of a current model should be passed if we are traversing
$arg_name = $m->table . '_id';
$arg_val = $this->app->stickyGet($arg_name);
$arg_val = $this->getApp()->stickyGet($arg_name);

if ($arg_val === null) {
throw (new Exception('Argument value is not specified'))
Expand Down
13 changes: 7 additions & 6 deletions src/MethodExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

declare(strict_types=1);

namespace atk4\mastercrud;
namespace Atk4\MasterCrud;

use atk4\data\Model;
use atk4\ui\Console;
use atk4\ui\Form;
use atk4\ui\View;
use Atk4\Core\SessionTrait;
use Atk4\Data\Model;
use Atk4\Ui\Console;
use Atk4\Ui\Form;
use Atk4\Ui\View;

/**
* This component will display a form and a console. After filling out the form, the values
Expand All @@ -24,7 +25,7 @@
*/
class MethodExecutor extends View
{
use \atk4\core\SessionTrait;
use SessionTrait;

/** @var Model */
public $model;
Expand Down
6 changes: 3 additions & 3 deletions tests/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace atk4\ui\tests;
namespace Atk4\MasterCrud\Tests;

use atk4\core\AtkPhpunit;
use Atk4\Core\AtkPhpunit;

class BasicTest extends AtkPhpunit\TestCase
{
Expand All @@ -13,6 +13,6 @@ class BasicTest extends AtkPhpunit\TestCase
*/
public function testTesting()
{
$this->assertSame('foo', 'foo');
$this->assertTrue(true);
}
}

0 comments on commit bccc12d

Please sign in to comment.