From a05417c57b4dc5cf9d1277e46646c24324b96e4d Mon Sep 17 00:00:00 2001 From: vedatakd Date: Tue, 24 Dec 2019 18:49:35 +0300 Subject: [PATCH] get Detail function on twig for Address and Location Module --- .../src/City/Command/GetCity.php | 34 +++++++++++++++++++ .../src/Country/Command/GetCountry.php | 33 ++++++++++++++++++ .../src/LocationModulePlugin.php | 24 +++++++++++++ .../src/Adress/Command/GetAddress.php | 34 +++++++++++++++++++ .../src/ProfileModulePlugin.php | 12 +++++++ 5 files changed, 137 insertions(+) create mode 100644 addons/default/visiosoft/location-module/src/City/Command/GetCity.php create mode 100644 addons/default/visiosoft/location-module/src/Country/Command/GetCountry.php create mode 100644 addons/default/visiosoft/profile-module/src/Adress/Command/GetAddress.php diff --git a/addons/default/visiosoft/location-module/src/City/Command/GetCity.php b/addons/default/visiosoft/location-module/src/City/Command/GetCity.php new file mode 100644 index 000000000..efe367a10 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/City/Command/GetCity.php @@ -0,0 +1,34 @@ +id = $id; + } + + + /** + * @param CityModel $groups + * @return |null + */ + public function handle(CityModel $groups) + { + if ($this->id) { + return $groups->find($this->id); + } + return null; + } +} diff --git a/addons/default/visiosoft/location-module/src/Country/Command/GetCountry.php b/addons/default/visiosoft/location-module/src/Country/Command/GetCountry.php new file mode 100644 index 000000000..0e41d4925 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Country/Command/GetCountry.php @@ -0,0 +1,33 @@ +id = $id; + } + + /** + * @param CountryModel $groups + * @return |null + */ + public function handle(CountryModel $groups) + { + if ($this->id) { + return $groups->find($this->id); + } + return null; + } +} diff --git a/addons/default/visiosoft/location-module/src/LocationModulePlugin.php b/addons/default/visiosoft/location-module/src/LocationModulePlugin.php index 23db88713..9d9d16ff9 100644 --- a/addons/default/visiosoft/location-module/src/LocationModulePlugin.php +++ b/addons/default/visiosoft/location-module/src/LocationModulePlugin.php @@ -1,6 +1,8 @@ dispatch(new GetCity($id))) { + return null; + } + + return $ad; + } + ), + new \Twig_SimpleFunction( + 'getCountry', + function ($id) { + + if (!$ad = $this->dispatch(new GetCountry($id))) { + return null; + } + return $ad; } ), diff --git a/addons/default/visiosoft/profile-module/src/Adress/Command/GetAddress.php b/addons/default/visiosoft/profile-module/src/Adress/Command/GetAddress.php new file mode 100644 index 000000000..03a326442 --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Adress/Command/GetAddress.php @@ -0,0 +1,34 @@ +id = $id; + } + + /** + * @param AdressRepositoryInterface $adressRepository + * @return \Anomaly\Streams\Platform\Model\EloquentModel|null + */ + public function handle(AdressRepositoryInterface $adressRepository) + { + if ($this->id) { + return $adressRepository->find($this->id); + } + return null; + } +} diff --git a/addons/default/visiosoft/profile-module/src/ProfileModulePlugin.php b/addons/default/visiosoft/profile-module/src/ProfileModulePlugin.php index 749ee3007..8f6e6a8cf 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModulePlugin.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModulePlugin.php @@ -1,6 +1,7 @@ dispatch(new GetAddress($id))) { + return null; + } + return $ad; } )