Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.0 KiB

  1. <?php
  2. namespace Grav\Plugin\FlexObjects\Events;
  3. use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
  4. use Grav\Framework\Flex\Interfaces\FlexDirectoryInterface;
  5. use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
  6. use Grav\Framework\Object\Interfaces\ObjectInterface;
  7. use Grav\Plugin\FlexObjects\Controllers\AbstractController;
  8. /**
  9. * @template T as FlexObjectInterface
  10. * @template C as FlexCollectionInterface
  11. */
  12. class FlexTaskEvent
  13. {
  14. /** @var string */
  15. public $task;
  16. /** @var string */
  17. public $type;
  18. /** @var string */
  19. public $key;
  20. /** @var ObjectInterface */
  21. private $object;
  22. /** @var AbstractController */
  23. private $controller;
  24. /**
  25. * @param AbstractController $controller
  26. * @param string $task
  27. */
  28. public function __construct(AbstractController $controller, ObjectInterface $object, string $task)
  29. {
  30. $this->task = $task;
  31. $this->type = $controller->getDirectoryType();
  32. $this->key = $controller->getObjectKey();
  33. $this->object = $object;
  34. $this->controller = $controller;
  35. }
  36. /**
  37. * @return AbstractController
  38. */
  39. public function getController(): AbstractController
  40. {
  41. return $this->controller;
  42. }
  43. /**
  44. * @return FlexDirectoryInterface
  45. */
  46. public function getDirectory(): FlexDirectoryInterface
  47. {
  48. return $this->getController()->getDirectory();
  49. }
  50. /**
  51. * @return FlexObjectInterface
  52. * @phpstan-return T
  53. */
  54. public function getModifiedObject(): FlexObjectInterface
  55. {
  56. return $this->object;
  57. }
  58. /**
  59. * @return FlexObjectInterface
  60. * @phpstan-return T
  61. */
  62. public function getOriginalObject(): FlexObjectInterface
  63. {
  64. return $this->controller->getObject();
  65. }
  66. /**
  67. * @return FlexCollectionInterface
  68. * @phpstan-return C
  69. */
  70. public function getCollection(): FlexCollectionInterface
  71. {
  72. return $this->getController()->getDirectory()->getCollection();
  73. }
  74. }