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

Commit

Permalink
Merge branch 'feature/model-registry-develop' of https://github.com/t…
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Oct 10, 2013
2 parents fe735c4 + 04ea677 commit dcd2cd1
Show file tree
Hide file tree
Showing 11 changed files with 557 additions and 120 deletions.
2 changes: 1 addition & 1 deletion assets/contao/css/debug-uncompressed.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#debug .time {
background:url("../../../system/themes/default/images/news.gif") left 0 no-repeat;
}
#debug .memory {
#debug .memory,#debug .models {
background:url("../../../system/themes/default/images/modules.gif") left 0 no-repeat;
}
#debug .db {
Expand Down
2 changes: 1 addition & 1 deletion assets/contao/css/debug.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions system/docs/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,32 @@ public function addAliasButton($arrButtons)

In case you have been using the "buttons_callback", please make sure to adjust
your extension accordingly.


### `Model::save()`

In Contao 3.0 and 3.1 it was possible to create two models for the same database
record by passing `true` to the `Model::save()` method. However, this could lead
to a loss of data in certain edge-cases, so we have decided to implement a model
registry to ensure that there is only one model per database record.

The registry, however, requires to use the `clone` command to duplicate models,
therefore the `$blnForceInsert` argment had to be removed. If you have used it
in your custom extension, be sure to adjust the code accordingly.

Usage in Contao 3.0 and 3.1:

```php
$objPage = PageModel::findByPK(1);
$objPage->title = 'New page title';
$objPage->save(true);
```

New usage as of Contao 3.2:

```php
$objPage = PageModel::findByPK(1);
$objCopy = clone $objPage;
$objCopy->title = 'New page title';
$objCopy->save();
```
1 change: 1 addition & 0 deletions system/helper/ide_compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class Php extends \Contao\Files\Php {}
namespace Model {
class Collection extends \Contao\Model\Collection {}
class QueryBuilder extends \Contao\Model\QueryBuilder {}
class Registry extends \Contao\Model\Registry {}
}

// devtools
Expand Down
1 change: 1 addition & 0 deletions system/modules/core/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
'Contao\Message' => 'system/modules/core/library/Contao/Message.php',
'Contao\Model\Collection' => 'system/modules/core/library/Contao/Model/Collection.php',
'Contao\Model\QueryBuilder' => 'system/modules/core/library/Contao/Model/QueryBuilder.php',
'Contao\Model\Registry' => 'system/modules/core/library/Contao/Model/Registry.php',
'Contao\Model' => 'system/modules/core/library/Contao/Model.php',
'Contao\ModuleLoader' => 'system/modules/core/library/Contao/ModuleLoader.php',
'Contao\Pagination' => 'system/modules/core/library/Contao/Pagination.php',
Expand Down
Loading

0 comments on commit dcd2cd1

Please sign in to comment.