[TYPO3-mvc] Domain model records without pid-column
dennis ahrens
dennis.ahrens at googlemail.com
Tue May 18 15:27:09 CEST 2010
Hi list,
In the past i've posted an issue on forge which allows you to set a
configuration in TCA that excludes the pid column for a table.
http://forge.typo3.org/issues/show/6899
Some Refactoring where done in the Persistence-Layer and my guessed
way is no longer available. Now i'd like to switch from rev 2042 back
to HEAD-rev - thats why i need a solution for this problem.
I've created a domain model for the sys_lockedrecords table to create
and delete record locks from within my controller by using the domain
layer of extbase.
mysql> desc sys_lockedrecords;
+--------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------------+------+-----+---------+----------------+
| uid | int(11) unsigned | NO | PRI | NULL | auto_increment |
| userid | int(11) unsigned | NO | MUL | 0 | |
| tstamp | int(11) unsigned | NO | | 0 | |
| record_table | varchar(255) | YES | | | |
| record_uid | int(11) | NO | | 0 | |
| record_pid | int(11) | NO | | 0 | |
| username | varchar(20) | NO | | | |
| feuserid | int(11) unsigned | NO | | 0 | |
+--------------+------------------+------+-----+---------+----------------+
There are the following Domain Classes involved:
Tx_FhhLib_Domain_Model_LockedRecord
Tx_FhhLib_Domain_Repository_LockedRecordRepository
In my extjs based BE-Module i have to register that a record will be
edited by a user by sending an ajax call to a controller which
provides the actions:
public function registerEditAction($recordUid, $recordType) { ... }
public function unregisterEditAction($recordUid, $recordType) { ... }
Both actions use a service that provides:
public function register(Tx_Extbase_DomainObject_AbstractEntity
$record) { ... }
public function getRegistered(Tx_Extbase_DomainObject_AbstractEntity
$record) { ... }
public function unregister(Tx_Extbase_DomainObject_AbstractEntity
$record) { ... }
to manage the Locks and send back messages based on the result.
The following Error occurs when adding a new LockedRecord Object into
its repository:
#1247602160: Unknown column 'pid' in 'field list'
I've digged deeper in the current way extbase inserts new objects.
The PersistenceBackend evaluates the storagePid for a new Record like this:
if ($object->_isNew() && !isset($row['pid'])) {
$row['pid'] = $this->determineStoragePageIdForNewRecord($object);
}
The determineStoragePageIdForNewRecord-method resolves pid Values from
the TS-configuration but a pid field will *always* be set.
At the moment we have the 'rule':
domain object *must have* pid-column in DB-model.
Do you think it is the wrong way to define a model for a table like
sys_lockedrecords?
Of course it is something like a relation table, but the relation
itself is an object -> the lock.
If it is intended to have a pid column for each model, how to manage a
request like this?
- Adding the pid-column for the sys_lockedrecords table? A Lock is not
related to page i think.
- Doing the persistence manually inside the service without using a
domain object and repository?
- Modelling the sys_lockedrecords table as mm-relation between the
object the should be inserted there and the assigned BackendUser?
Yesterday i had a look at sys_history and sys_log which are
responsible for the record history. I've thought about making them
available in extbase - both tables have no pid-column...
Any hints to solve this problem are really welcome :)
regards
dennis
More information about the TYPO3-project-typo3v4mvc
mailing list