GreedyCommentsTable.php 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. namespace TestApp\Model\Table;
  4. use Cake\ORM\Query\SelectQuery;
  5. use Cake\ORM\Table;
  6. /**
  7. * Test stub for greedy find operations.
  8. */
  9. class GreedyCommentsTable extends Table
  10. {
  11. /**
  12. * initialize hook
  13. *
  14. * @param array $config Config data.
  15. */
  16. public function initialize(array $config): void
  17. {
  18. $this->setTable('comments');
  19. $this->setAlias('Comments');
  20. }
  21. /**
  22. * Overload find to cause issues.
  23. *
  24. * @param string $type Find type
  25. * @param mixed ...$args Arguments that match up to finder-specific parameters
  26. */
  27. public function find(string $type = 'all', mixed ...$args): SelectQuery
  28. {
  29. $options = &$args[0];
  30. if (empty($options['conditions'])) {
  31. $options['conditions'] = [];
  32. }
  33. $options['conditions'] = array_merge($options['conditions'], ['Comments.published' => 'Y']);
  34. return parent::find($type, ...$options);
  35. }
  36. }