add utils
This commit is contained in:
parent
f229d2009b
commit
52f398f2a3
|
@ -1 +1,37 @@
|
|||
# Doctrine
|
||||
|
||||
## Timestampable
|
||||
|
||||
`App\Core\Doctrine\Timestampable` is a trait usuble in an entity. It adds `createdAt and updatedAt` datetime attributes with the setters and the getters :
|
||||
|
||||
* `setCreatedAt(?\DateTime $createdAt): self`
|
||||
* `setUpdated(?\DateTime $createdAt): self`
|
||||
* `getCreatedAt(): ?\DateTime`
|
||||
* `getUpdatedAt(): ?\DateTime`
|
||||
|
||||
When the entity is created or updated, `createdAt` and `updatedAt` are automatically updated to.
|
||||
|
||||
### Usage
|
||||
|
||||
```
|
||||
// App/Entity/FooEntity;
|
||||
|
||||
use use App\Core\Entity\EntityInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use App\Core\Doctrine\Timestampable;
|
||||
use App\Core\Entity\EntityInterface;
|
||||
use App\Repository\FooRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=FooRepository::class)
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class FooEntity implements EntityInterface
|
||||
{
|
||||
use Timestampable;
|
||||
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
|
|
@ -12,6 +12,8 @@ Useful methods:
|
|||
* `setAttachments(array $attachments): MailNotifier`
|
||||
* `addRecipient(string $email, bool $isBcc = false): MailNotifier`
|
||||
* `addRecipients(array $emails, bool $isBcc = false): MailNotifier`
|
||||
* `addRecipientByUser(\App\Entity\User $user, bool $isBcc = false): self`
|
||||
* `addRecipientsByUsers($users, bool $isBcc = false): self`
|
||||
* `addAttachment(string $attachment): MailNotifier`
|
||||
* `addAttachments(array $attachments): MailNotifier`
|
||||
* `init(): MailNotifier`
|
||||
|
@ -21,8 +23,9 @@ Exemple:
|
|||
|
||||
```
|
||||
use App\Core\Notification\MailNotifier;
|
||||
use App\Repository\UserRepositoryQuery;
|
||||
|
||||
public function foo(MailNotifier $notifier)
|
||||
public function foo(MailNotifier $notifier, UserRepositoryQuery $query)
|
||||
{
|
||||
// ...
|
||||
|
||||
|
@ -30,10 +33,7 @@ public function foo(MailNotifier $notifier)
|
|||
->init()
|
||||
->setSubject('Your bill')
|
||||
->addRecipient('john.doe@example.com')
|
||||
->addRecipients([
|
||||
'admin@example-shop.com',
|
||||
'sales@example-shop.com',
|
||||
], true)
|
||||
->addRecipients($query->create()->where('.isAdmin = true')->find(), true)
|
||||
->addAttachment('path/to/bill.pdf')
|
||||
->notify('mail/bill.html.twig', [
|
||||
// view params
|
||||
|
|
Loading…
Reference in a new issue