-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from delyriand/feautre/add-custom-factory
Add custom factory and template events to facilitate override when form fields
- Loading branch information
Showing
6 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz' Contact Request plugin for Sylius. | ||
* (c) Monsieur Biz <[email protected]> | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusContactRequestPlugin\Factory; | ||
|
||
use MonsieurBiz\SyliusContactRequestPlugin\Entity\ContactRequestInterface; | ||
use Sylius\Component\Core\Model\ChannelInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
|
||
final class ContactRequestFactory implements ContactRequestFactoryInterface | ||
{ | ||
public function __construct(private FactoryInterface $factory) | ||
{ | ||
} | ||
|
||
public function createNew(): ContactRequestInterface | ||
{ | ||
// @phpstan-ignore-next-line | ||
return $this->factory->createNew(); | ||
} | ||
|
||
public function createNewFromChannelAndData(ChannelInterface $channel, array $data): ContactRequestInterface | ||
{ | ||
$contactRequest = $this->createNew(); | ||
$contactRequest->setEmail($data['email']); | ||
$contactRequest->setMessage($data['message']); | ||
$contactRequest->setChannel($channel); | ||
|
||
return $contactRequest; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Monsieur Biz' Contact Request plugin for Sylius. | ||
* (c) Monsieur Biz <[email protected]> | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MonsieurBiz\SyliusContactRequestPlugin\Factory; | ||
|
||
use MonsieurBiz\SyliusContactRequestPlugin\Entity\ContactRequestInterface; | ||
use Sylius\Component\Core\Model\ChannelInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
|
||
/** | ||
* @method ContactRequestInterface createNew() | ||
*/ | ||
interface ContactRequestFactoryInterface extends FactoryInterface | ||
{ | ||
public function createNewFromChannelAndData(ChannelInterface $channel, array $data): ContactRequestInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters