ResetCommentsTable.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace TestApp\Model\Table;
  3. use Tools\Model\Table\Table;
  4. use Cake\ORM\Entity;
  5. class ResetCommentsTable extends Table {
  6. public function initialize(array $config) {
  7. $this->displayField('comment');
  8. parent::initialize($config);
  9. }
  10. public function customCallback(Entity $record, &$updateFields) {
  11. $record->comment .= ' xyz';
  12. $fields[] = 'some_other_field';
  13. return $record;
  14. }
  15. public function customObjectCallback(Entity $record, &$updateFields) {
  16. $record['comment'] .= ' xxx';
  17. $updateFields[] = 'some_other_field';
  18. return $record;
  19. }
  20. public static function customStaticCallback(Entity $record, &$updateFields) {
  21. $record['comment'] .= ' yyy';
  22. $updateFields[] = 'some_other_field';
  23. return $record;
  24. }
  25. public static function fieldsCallback(Entity $record, &$updateFields) {
  26. $record['comment'] = 'foo';
  27. return $record;
  28. }
  29. public static function fieldsCallbackAuto(Entity $record, &$updateFields) {
  30. $record['comment'] = 'bar';
  31. $updateFields[] = 'comment';
  32. return $record;
  33. }
  34. }