Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Fixed the deprecations and bumped the minimum cakephp version
Browse files Browse the repository at this point in the history
  • Loading branch information
David Yell committed Jun 25, 2019
1 parent da28edb commit a921f81
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 189 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -13,8 +13,8 @@
}
],
"require": {
"php": ">=5.6",
"cakephp/cakephp": "^3.4",
"php": ">=7.0",
"cakephp/cakephp": "^3.7",
"friendsofcake/bootstrap-ui": "~1.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Bake/Element/Controller/add.ctp
Expand Up @@ -11,7 +11,7 @@ $compact = ["'" . $singularName . "'"];
{
$<%= $singularName %> = $this-><%= $currentModelName %>->newEntity();
if ($this->request->is('post')) {
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->data);
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->getRequest()->getData());
if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) {
$this->Flash->success(__('The <%= strtolower($singularHumanName) %> has been saved.'));

Expand Down
2 changes: 1 addition & 1 deletion src/Template/Bake/Element/Controller/edit.ctp
Expand Up @@ -28,7 +28,7 @@ $compact = ["'" . $singularName . "'"];
]);

if ($this->request->is(['patch', 'post', 'put'])) {
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->request->getData());
$<%= $singularName %> = $this-><%= $currentModelName %>->patchEntity($<%= $singularName %>, $this->getRequest()->getData());
if ($this-><%= $currentModelName; %>->save($<%= $singularName %>)) {
$this->Flash->success(__('The <%= strtolower($singularHumanName) %> has been saved.'));

Expand Down
6 changes: 3 additions & 3 deletions src/Template/Bake/Element/form.ctp
Expand Up @@ -3,7 +3,7 @@ use Cake\Utility\Inflector;

$fields = collection($fields)
->filter(function($field) use ($schema) {
return $schema->columnType($field) !== 'binary';
return $schema->getColumnType($field) !== 'binary';
});
%>
<div class="<%= $pluralVar %> form">
Expand All @@ -17,7 +17,7 @@ $fields = collection($fields)
continue;
}
if (isset($keyFields[$field])) {
$fieldData = $schema->column($field);
$fieldData = $schema->getColumn($field);
if (!empty($fieldData['null'])) {
%>
echo $this->Form->control('<%= $field %>', ['options' => $<%= $keyFields[$field] %>, 'empty' => true]);
Expand All @@ -30,7 +30,7 @@ $fields = collection($fields)
continue;
}
if (!in_array($field, ['created', 'modified', 'updated'])) {
$fieldData = $schema->column($field);
$fieldData = $schema->getColumn($field);
if (($fieldData['type'] === 'date') && (!empty($fieldData['null']))) {
%>
echo $this->Form->control('<%= $field %>', ['empty' => true, 'default' => '']);
Expand Down
172 changes: 0 additions & 172 deletions src/Template/Bake/Model/table.ctp

This file was deleted.

16 changes: 8 additions & 8 deletions src/Template/Bake/Template/index.ctp
Expand Up @@ -3,11 +3,11 @@ use Cake\Utility\Inflector;

$fields = collection($fields)
->filter(function($field) use ($schema) {
return !in_array($schema->columnType($field), ['binary', 'text']);
return !in_array($schema->getColumnType($field), ['binary', 'text']);
})
->take(7);
%>
<h1><?= $this->request->controller?></h1>
<h1><?= $this->getRequest()->getParam('controller')?></h1>

<div class="buttons">
<?= $this->Html->link('<span class=\'glyphicon glyphicon-plus\'></span> Add new', ['action' => 'add'], ['class' => 'btn btn-primary', 'escape' => false]);?>
Expand All @@ -29,11 +29,11 @@ $fields = collection($fields)
<tr>
<% foreach ($fields as $field):
$class = '';
if (in_array($schema->columnType($field), ['integer', 'biginteger', 'decimal', 'float'])) {
if (in_array($schema->getColumnType($field), ['integer', 'biginteger', 'decimal', 'float'])) {
$class = ' class="number"';
} elseif (in_array($schema->columnType($field), ['date', 'datetime', 'timestamp', 'time'])) {
} elseif (in_array($schema->getColumnType($field), ['date', 'datetime', 'timestamp', 'time'])) {
$class = ' class="time"';
} elseif (in_array($schema->columnType($field), ['boolean'])) {
} elseif (in_array($schema->getColumnType($field), ['boolean'])) {
$class = ' class="boolean"';
}
%>
Expand Down Expand Up @@ -61,15 +61,15 @@ $fields = collection($fields)
}
}
if ($isKey !== true) {
if (in_array($schema->columnType($field), ['integer', 'biginteger', 'decimal', 'float'])) {
if (in_array($schema->getColumnType($field), ['integer', 'biginteger', 'decimal', 'float'])) {
%>
<td class="number"><?= $this->Number->format($<%= $singularVar %>->get('<%= $field %>')) ?></td>
<%
} elseif (in_array($schema->columnType($field), ['date', 'datetime', 'timestamp', 'time'])) {
} elseif (in_array($schema->getColumnType($field), ['date', 'datetime', 'timestamp', 'time'])) {
%>
<td class="time"><?= $this->Time->timeAgoInWords($<%= $singularVar %>->get('<%= $field %>')) ?></td>
<%
} elseif (in_array($schema->columnType($field), ['boolean'])) {
} elseif (in_array($schema->getColumnType($field), ['boolean'])) {
%>
<td class="boolean"><?php
if ($<%= $singularVar %>->get('<%= $field %>')) {
Expand Down
4 changes: 2 additions & 2 deletions src/Template/Bake/Template/view.ctp
Expand Up @@ -18,10 +18,10 @@ $associationFields = collection($fields)

$groupedFields = collection($fields)
->filter(function($field) use ($schema) {
return $schema->columnType($field) !== 'binary';
return $schema->getColumnType($field) !== 'binary';
})
->groupBy(function($field) use ($schema, $associationFields) {
$type = $schema->columnType($field);
$type = $schema->getColumnType($field);
if (isset($associationFields[$field])) {
return 'string';
}
Expand Down

0 comments on commit a921f81

Please sign in to comment.