Skip to content

Commit

Permalink
Upgrade atk4/data with strict entity model (#1623)
Browse files Browse the repository at this point in the history
Co-authored-by: Alain Belair <[email protected]>
  • Loading branch information
mvorisek and ibelar authored May 5, 2021
1 parent 0cd03dd commit 3e4e041
Show file tree
Hide file tree
Showing 58 changed files with 125 additions and 122 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ $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);
$m = $m->load(2);
\Atk4\Ui\Form::addTo($p)->setModel($m);
});
```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"require-release": {
"php": ">=7.3.0",
"atk4/data": "~2.5.0"
"atk4/data": "~3.0.0"
},
"require-dev": {
"behat/behat": "^3.8",
Expand Down
8 changes: 4 additions & 4 deletions demos/_demo-data/create-sqlite-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,10 @@ public function import(array $rowsMulti)
$model->addField('updated', ['type' => 'datetime']);
(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'],
['id' => 3, 'project_name' => 'Agile Data', 'project_code' => 'at03', 'description' => 'Agile Data implements an entirely new pattern for data abstraction, that is specifically designed for remote databases such as RDS, Cloud SQL, BigQuery and other distributed data storage architectures. It focuses on reducing number of requests your App have to send to the Database by using more sophisticated queries while also offering full Domain Model mapping and Database vendor abstraction.', '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' => 12000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 300, 'project_hours_reported' => 394, 'project_expenses_est' => 600, 'project_expenses' => 430, 'project_mgmt_cost_pct' => 0.2, 'project_qa_cost_pct' => 0.3, 'start_date' => '2016-04-17', 'finish_date' => '2016-06-20', 'finish_time' => '03:04:00', 'created' => '2017-04-06 10:30:15', 'updated' => '2017-04-06 10:35:04'],
['id' => 4, 'project_name' => 'Agile UI', 'project_code' => 'at04', 'description' => 'Web UI Component library.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,\nGarden City\nUK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 0, 'project_budget' => 20000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 600, 'project_hours_reported' => 368, 'project_expenses_est' => 1200, 'project_expenses' => 0, 'project_mgmt_cost_pct' => 0.3, 'project_qa_cost_pct' => 0.4, 'start_date' => '2016-09-17', 'finish_date' => '', 'finish_time' => '', 'created' => '2017-04-06 10:30:15', 'updated' => '2017-04-06 10:35:04'],
['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,' . "\n" . 'Garden City' . "\n" . 'UK', '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,' . "\n" . 'Garden City' . "\n" . 'UK', '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'],
['id' => 3, 'project_name' => 'Agile Data', 'project_code' => 'at03', 'description' => 'Agile Data implements an entirely new pattern for data abstraction, that is specifically designed for remote databases such as RDS, Cloud SQL, BigQuery and other distributed data storage architectures. It focuses on reducing number of requests your App have to send to the Database by using more sophisticated queries while also offering full Domain Model mapping and Database vendor abstraction.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,' . "\n" . 'Garden City' . "\n" . 'UK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 1, 'project_budget' => 12000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 300, 'project_hours_reported' => 394, 'project_expenses_est' => 600, 'project_expenses' => 430, 'project_mgmt_cost_pct' => 0.2, 'project_qa_cost_pct' => 0.3, 'start_date' => '2016-04-17', 'finish_date' => '2016-06-20', 'finish_time' => '03:04:00', 'created' => '2017-04-06 10:30:15', 'updated' => '2017-04-06 10:35:04'],
['id' => 4, 'project_name' => 'Agile UI', 'project_code' => 'at04', 'description' => 'Web UI Component library.', 'client_name' => 'Agile Toolkit', 'client_address' => 'Some Street,' . "\n" . 'Garden City' . "\n" . 'UK', 'client_country_iso' => 'GB', 'is_commercial' => 0, 'currency' => 'GBP', 'is_completed' => 0, 'project_budget' => 20000, 'project_invoiced' => 0, 'project_paid' => 0, 'project_hour_cost' => 0, 'project_hours_est' => 600, 'project_hours_reported' => 368, 'project_expenses_est' => 1200, 'project_expenses' => 0, 'project_mgmt_cost_pct' => 0.3, 'project_qa_cost_pct' => 0.4, 'start_date' => '2016-09-17', 'finish_date' => '', 'finish_time' => '', 'created' => '2017-04-06 10:30:15', 'updated' => '2017-04-06 10:35:04'],
]);

$model = new ImportModelWithPrefixedFields($persistence, ['table' => 'product_category']);
Expand Down
8 changes: 5 additions & 3 deletions demos/_includes/DemoActionsUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Atk4\Ui\Demos;

use Atk4\Data\Model\UserAction;

class DemoActionsUtil
{
public static function setupDemoActions(CountryLock $country): void
Expand Down Expand Up @@ -82,8 +84,8 @@ public static function setupDemoActions(CountryLock $country): void
'edit_iso',
[
'caption' => 'Edit ISO3',
'description' => function ($action) {
return 'Edit ISO3 for country: ' . $action->getModel()->getTitle();
'description' => function (UserAction $action) {
return 'Edit ISO3 for country: ' . $action->getEntity()->getTitle();
},
'fields' => [$country->fieldName()->iso3],
'callback' => function () {
Expand Down Expand Up @@ -113,7 +115,7 @@ public static function setupDemoActions(CountryLock $country): void
'caption' => 'User Confirmation',
'description' => 'Confirm the action using a ConfirmationExecutor',
'confirmation' => function ($a) {
return 'Are you sure you want to perform this action on: <b>' . $a->getModel()->getTitle() . ' (' . $a->getModel()->iso3 . ')</b>';
return 'Are you sure you want to perform this action on: <b>' . $a->getEntity()->getTitle() . ' (' . $a->getEntity()->iso3 . ')</b>';
},
'callback' => function ($model) {
return 'Confirm country ' . $model->getTitle();
Expand Down
2 changes: 1 addition & 1 deletion demos/_unit-test/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$vp->cb->triggerOnReload = false;

$form = Form::addTo($vp);
$form->setModel((clone $m)->tryLoadAny(), [$m->fieldName()->name]);
$form->setModel($m->tryLoadAny(), [$m->fieldName()->name]);
$form->getControl($m->fieldName()->name)->caption = 'TestName';

$table = $app->add(new \Atk4\Ui\Table());
Expand Down
2 changes: 1 addition & 1 deletion demos/basic/breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

if ($id = $app->stickyGet('country_id')) {
// perhaps we edit individual country?
$model->load($id);
$model = $model->load($id);
$crumb->addCrumb($model->name, []);

// here we can check for additional criteria and display a deeper level on the crumb
Expand Down
4 changes: 2 additions & 2 deletions demos/collection/crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function addFormTo(\Atk4\Ui\View $view): \Atk4\Ui\Form

$result = parent::addFormTo($left);

if ($this->action->getOwner()->get(File::hinting()->fieldName()->is_folder)) {
if ($this->action->getModel()->get(File::hinting()->fieldName()->is_folder)) {
\Atk4\Ui\Grid::addTo($right, ['menu' => false, 'ipp' => 5])
->setModel(File::assertInstanceOf($this->action->getOwner())->SubFolder);
->setModel(File::assertInstanceOf($this->action->getModel())->SubFolder);
} else {
\Atk4\Ui\Message::addTo($right, ['Not a folder', 'warning']);
}
Expand Down
2 changes: 1 addition & 1 deletion demos/collection/lister-ipp.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

$view = \Atk4\Ui\View::addTo($container, ['template' => new HtmlTemplate('<div>
<ul>
{List}<li class="ui icon label"><i class="{iso}ae{/} flag"></i> {name}andorra{/}</li>{/}
{List}<li class="ui icon label"><i class="{$atk_fp_country__iso} flag"></i>{$atk_fp_country__name}</li>{/}
</ul>{$Content}</div>')]);

$lister = \Atk4\Ui\Lister::addTo($view, [], ['List']);
Expand Down
2 changes: 1 addition & 1 deletion demos/collection/multitable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function setModel(\Atk4\Data\Model $model, $route = [])
while ($selections && $id = array_shift($selections)) {
$path[] = $id;
$pushModel = new $model($model->persistence);
$pushModel->tryLoad($id);
$pushModel = $pushModel->tryLoad($id);
if (!$pushModel->loaded()) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion demos/data-action/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
$executor->description = 'Only fields set in $action[field] array will be added in form.';
$executor->setArguments(['path' => '.']);
$executor->onHook(UserAction\BasicExecutor::HOOK_AFTER_EXECUTE, function ($x, $ret) {
return new \Atk4\Ui\JsToast('Confirm! ' . $x->action->getModel()->name);
return new \Atk4\Ui\JsToast('Confirm! ' . $x->action->getEntity()->name);
});

View::addTo($leftColumn, ['ui' => 'hidden divider']);
Expand Down
4 changes: 2 additions & 2 deletions demos/data-action/factory-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function getCardButton($action, $type)
Header::addTo($app, ['Executor Factory set for this Card View only.']);

DemoActionsUtil::setupDemoActions($country = new CountryLock($app->db));
$country->loadAny();
$country = $country->loadAny();

$cardActions = Card::addTo($app, ['useLabel' => true, 'executorFactory' => new $myFactory()]);
$cardActions->setModel($country);
Expand All @@ -65,7 +65,7 @@ protected function getCardButton($action, $type)
Header::addTo($app, ['Card View using global Executor Factory']);

$model = new CountryLock($app->db);
$model->loadAny();
$model = $model->loadAny();

$card = Card::addTo($app, ['useLabel' => true]);
$card->setModel($model);
Expand Down
8 changes: 5 additions & 3 deletions demos/data-action/jsactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Atk4\Ui\Demos;

use Atk4\Data\Model\UserAction;
use Atk4\Ui\Form\Control\Line;
use Atk4\Ui\UserAction\JsCallbackExecutor;

Expand All @@ -21,7 +22,7 @@
$sendEmailAction = $country->addUserAction('Email', [
'confirmation' => 'Are you sure you wish to send an email?',
'callback' => function (Country $country) {
return 'Email to Kristy in ' . $country->fieldName()->name . ' has been sent!';
return 'Email to Kristy in ' . $country->name . ' has been sent!';
},
]);

Expand All @@ -37,6 +38,7 @@

// Note here that we explicitly required a JsCallbackExecutor for the greet action.
$country->addUserAction('greet', [
'appliesTo' => UserAction::APPLIES_TO_NO_RECORDS,
'args' => [
'name' => [
'type' => 'string',
Expand Down Expand Up @@ -72,7 +74,7 @@
$card->addDescription('Kristy is a friend of Mully.');

$s = $card->addSection('Country');
$s->addFields($country->loadAny(), [$country->fieldName()->name, $country->fieldName()->iso]);
$s->addFields($entity = $country->loadAny(), [$country->fieldName()->name, $country->fieldName()->iso]);

// Pass the model action to the Card::addClickAction() method.
$card->addClickAction($sendEmailAction);
$card->addClickAction($sendEmailAction, null, ['id' => $entity->getId()]);
7 changes: 3 additions & 4 deletions demos/data-action/jsactions2.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// Demo for Model action

$country = new CountryLock($app->db);
$country->tryLoadAny();
$countryId = $country->getId();
$entity = $country->tryLoadAny();
$countryId = $entity->getId();

// Model actions for this file are setup in DemoActionUtil.
DemoActionsUtil::setupDemoActions($country);
Expand All @@ -29,11 +29,10 @@
$gl = \Atk4\Ui\GridLayout::addTo($app, ['rows' => 1, 'columns' => 2]);
$c = \Atk4\Ui\Card::addTo($gl, ['useLabel' => true], ['r1c1']);
$c->addContent(new \Atk4\Ui\Header(['Using country: ']));
$c->setModel($country, [$country->fieldName()->iso, $country->fieldName()->iso3, $country->fieldName()->phonecode]);
$c->setModel($entity, [$country->fieldName()->iso, $country->fieldName()->iso3, $country->fieldName()->phonecode]);

$buttons = \Atk4\Ui\View::addTo($gl, ['ui' => 'vertical basic buttons'], ['r1c2']);

$country->unload();
// Create a button for every action in Country model.
foreach ($country->getUserActions() as $action) {
$b = \Atk4\Ui\Button::addTo($buttons, [$action->getCaption()]);
Expand Down
2 changes: 1 addition & 1 deletion demos/form-control/lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'plus' => true,
]]]);

$form->setModel($model);
$form->setModel($model->createEntity());

$form->addControl('country3', [
Form\Control\Lookup::class,
Expand Down
2 changes: 1 addition & 1 deletion demos/form-control/multiline.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function ($v) {
// Populate some data.
$total = 0;
for ($i = 1; $i < 3; ++$i) {
$inventory2 = clone $inventory;
$inventory2 = $inventory->createEntity();
$inventory2->set('id', $i);
$inventory2->set('inv_date', date($dateFormat));
$inventory2->set('inv_time', date($timeFormat));
Expand Down
2 changes: 1 addition & 1 deletion demos/form/form-section.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
\Atk4\Ui\View::addTo($app, ['ui' => 'ui clearing divider']);

$model = new CountryLock($app->db);
$model->loadAny();
$model = $model->loadAny();

// Prevent form from saving
$noSave = function (Form $form) {
Expand Down
3 changes: 2 additions & 1 deletion demos/form/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
$modelRegister->addField('name');
$modelRegister->addField('email');
$modelRegister->addField('is_accept_terms', ['type' => 'boolean', 'mandatory' => true]);
$modelRegister = $modelRegister->createEntity();

$form = Form::addTo($tab, ['segment' => true]);
$form->setModel($modelRegister);
Expand All @@ -195,7 +196,7 @@
\Atk4\Ui\Header::addTo($tab, ['Shows example of grouping and multiple errors']);

$form = Form::addTo($tab, ['segment']);
$form->setModel(new \Atk4\Data\Model());
$form->setModel((new \Atk4\Data\Model())->createEntity());

$form->addHeader('Example fields added one-by-one');
$form->addControl('name');
Expand Down
4 changes: 2 additions & 2 deletions demos/form/form2.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//$form = Form::addTo($app, ['segment', 'buttonSave'=>[null, 'Import', 'secondary', 'iconRight'=>'list']]);
\Atk4\Ui\Label::addTo($form, ['Input new country information here', 'top attached'], ['AboveControls']);

$form->setModel(new Country($app->db), false);
$form->setModel((new Country($app->db))->createEntity(), false);

// form basic field group
$formAddress = $form->addGroup('Basic Country Information');
Expand Down Expand Up @@ -102,4 +102,4 @@ public function validate($intent = null): array

Form::addTo($app)
->addClass('segment')
->setModel(new $personClass($app->db));
->setModel((new $personClass($app->db))->createEntity());
4 changes: 2 additions & 2 deletions demos/form/form3.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
->on('click', new JsReload($seg, ['m' => 'stat']));

$form = Form::addTo($seg, ['layout' => [Form\Layout\Columns::class]]);
$form->setModel(
$form->setModel((
isset($_GET['m']) ? (
$_GET['m'] === 'country' ? new Country($app->db) : (
$_GET['m'] === 'file' ? new File($app->db) : new Stat($app->db)
)
) : new Stat($app->db)
)->tryLoadAny();
)->tryLoadAny());

$form->onSubmit(function (Form $form) {
$errors = [];
Expand Down
2 changes: 2 additions & 0 deletions demos/form/form5.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
// Form-specific caption overrides general caption of a field. Also you can specify object instead of seed
$model->addField('six', ['caption' => 'badcaption', 'ui' => ['form' => new Form\Control\Checkbox(['caption' => 'Caption4'])]]);

$model = $model->createEntity();

$form = Form::addTo($cc->addColumn());
$form->setModel($model);
$form->onSubmit($formSubmit);
Expand Down
6 changes: 3 additions & 3 deletions demos/form/html-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
Header::addTo($right, ['Button on right']);

$form = Form::addTo($right, ['layout' => [Form\Layout::class, 'defaultTemplate' => __DIR__ . '/templates/form-button-right.html']]);
$form->setModel(new Flyers(new \Atk4\Data\Persistence\Array_()));
$form->setModel((new Flyers(new \Atk4\Data\Persistence\Array_()))->tryLoadAny());
$form->getControl('last_name')->hint = 'Please enter your last name.';

$left = View::addTo($gridLayout, [], ['r1c2']);
Expand All @@ -47,14 +47,14 @@
],
],
]);
$form->setModel(new Flyers(new \Atk4\Data\Persistence\Array_()));
$form->setModel((new Flyers(new \Atk4\Data\Persistence\Array_()))->tryLoadAny());
$form->getControl('last_name')->hint = 'Please enter your last name.';

////////////////////////////////////////
$tab = $tabs->addTab('Custom layout class');

$form = Form::addTo($tab, ['layout' => [Form\Layout\Custom::class, 'defaultTemplate' => __DIR__ . '/templates/form-custom-layout.html']]);
$form->setModel(new \Atk4\Ui\Demos\CountryLock($app->db))->loadAny();
$form->setModel((new \Atk4\Ui\Demos\CountryLock($app->db))->loadAny());

$form->onSubmit(function ($form) {
return new \Atk4\Ui\JsToast('Saving is disabled');
Expand Down
8 changes: 3 additions & 5 deletions demos/init-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ public function validate($intent = null): array
}

// look if name is unique
$c = clone $this;
$c->unload();
$c->tryLoadBy($this->fieldName()->name, $this->name);
$c = $this->getModel()->tryLoadBy($this->fieldName()->name, $this->name);
if ($c->loaded() && $c->getId() !== $this->getId()) {
$errors[$this->fieldName()->name] = 'Country name must be unique';
}
Expand Down Expand Up @@ -295,7 +293,7 @@ public function importFromFilesystem($path, $isSub = false)
}

if ($name === 'src' || $name === 'demos' || $isSub) {
$m = clone $this;
$entity = $this->getModel(true)->createEntity();

/*
// Disabling saving file in db
Expand All @@ -307,7 +305,7 @@ public function importFromFilesystem($path, $isSub = false)
*/

if ($fileinfo->isDir()) {
$m->SubFolder->importFromFilesystem($dir->getPath() . '/' . $name, true);
$entity->SubFolder->importFromFilesystem($dir->getPath() . '/' . $name, true);
}
}
}
Expand Down
Loading

0 comments on commit 3e4e041

Please sign in to comment.