/**
  * Toggle the state.
  *
  * @param string $tableName Data container name.
  * @param int    $recordId  Data record id.
  * @param array  $data      Data of the row which should be changed.
  * @param mixed  $context   Context, usually the data container driver.
  *
  * @return array
  */
 public function update($tableName, $recordId, array $data, $context)
 {
     $this->guardUserHasAccess($tableName, $recordId, $data);
     $definition = $this->dcaManager->getDefinition($tableName);
     $versions = $this->initializeVersions($definition, $recordId);
     $data = $this->executeSaveCallbacks($definition, $data, $context);
     $this->save($definition, $recordId, $data);
     if ($versions) {
         $versions->create();
     }
     return $data;
 }
示例#2
0
 /**
  * Get a formatter.
  *
  * @param string|null $name Data definition name. If empty the default name is used.
  *
  * @return Formatter\Formatter
  */
 protected function getFormatter($name = null)
 {
     return $this->dcaManager->getFormatter($name ?: static::getName());
 }