diff --git a/changelog.md b/changelog.md index 4b6b176..70cb679 100644 --- a/changelog.md +++ b/changelog.md @@ -53,3 +53,8 @@ All notable changes to `laravel-mail-editor` will be documented in this file. ## Version 1.1.7 - Moving away templates metadata from DB to a JSON file to avoid production problems. + +## Version 1.1.10 + +- Fixes issues #15, #16 +- Adds the ability to have params mocked for a Mailable's constructor where a type isn't available diff --git a/composer.json b/composer.json index 26f0300..b7205e3 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "homepage": "https://github.com/Qoraiche/laravel-mail-editor", "keywords": ["Laravel", "mailEclipse", "mailable-editor", "laravel-mail", "laravel-mailable", "mailable", "markdown"], "require": { - "illuminate/support": "~5" + "illuminate/support": "~5", + "reecem/mocker": "1.1.*" }, "require-dev": { "phpunit/phpunit": "~7.0", diff --git a/src/mailEclipse.php b/src/mailEclipse.php index e4ec8bc..226acb6 100644 --- a/src/mailEclipse.php +++ b/src/mailEclipse.php @@ -15,6 +15,7 @@ use ReflectionClass; use ReflectionProperty; use RegexIterator; +use ReeceM\Mocker\ReflectionMockery; class mailEclipse { @@ -623,6 +624,8 @@ static public function handleMailableViewDataArgs($mailable) $reflection = new ReflectionClass($mailable); $params = $reflection->getConstructor()->getParameters(); + + $mocked = new ReflectionMockery($reflection); DB::beginTransaction(); @@ -686,9 +689,11 @@ static public function handleMailableViewDataArgs($mailable) } else { - - $filteredparams[] = $arg; - + try { + $filteredparams[] = $mocked->get($arg); + } catch (\Exception $e) { + $filteredparams[] = $arg; + } } } @@ -853,4 +858,4 @@ static public function renderPreview($simpleview = false, $view, $template = fal } } -} \ No newline at end of file +}