Skip to content

Commit

Permalink
CS
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar committed Apr 2, 2024
1 parent 19acf50 commit f54814a
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 46 deletions.
7 changes: 4 additions & 3 deletions src/BulkyItem/BulkyItemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ public function __construct(
}

/**
* Returns the voucher with which you can come back to the storage and get your bulky item back.
* Would probably also call this a "token" in a real world cloakroom but in order to not mess up
* the terminology with simple tokens etc., we're going for voucher here.
* Returns the voucher with which you can come back to the storage and get your
* bulky item back. Would probably also call this a "token" in a real world
* cloakroom but in order to not mess up the terminology with simple tokens etc.,
* we're going for voucher here.
*/
public function store(BulkyItemInterface $item): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ protected function removeRecipient($strEmail, $arrRemove): void
$tokens['channels'] = implode(', ', $arrChannels);
$tokens['channel_ids'] = implode(', ', $arrRemove);

// Make sending the notification optional so that you can use this module to NOT send any notification which is
// not possible in the Contao core
// Make sending the notification optional so that you can use this module to NOT
// send any notification which is not possible in the Contao core
if ($this->nc_notification) {
$this->notificationCenter->sendNotification((int) $this->nc_notification, $tokens);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/FrontendModule/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function sendNotification(int $memberId, OptInTokenInterface|null $optIn
}
}

$member = MemberModel::findByPk($memberId);
$member = MemberModel::findById($memberId);

if (null !== $member) {
foreach ($member->row() as $k => $v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ public function __construct(private readonly NotificationTypeRegistry $typeRegis
}

/**
* Adjust the operations to adjust the UX for 4.13 (pencil accesses messages, header.svg edits notification) and
* 5.x (pencil edits notification, children.svg accesses messages).
* Adjust the operations to adjust the UX for 4.13 (pencil accesses messages,
* header.svg edits notification) and 5.x (pencil edits notification, children.svg
* accesses messages).
*/
#[AsCallback(table: 'tl_nc_notification', target: 'config.onload')]
public function onLoadCallback(): void
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Newsletter/ActivationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __invoke(string $email, array $recipientIds, array $channelIds,

if ($module->nc_newsletter_activation_jumpTo) {
$targetPage = $this->contaoFramework->getAdapter(PageModel::class)
->findByPk($module->nc_newsletter_activation_jumpTo)
->findById($module->nc_newsletter_activation_jumpTo)
;

if ($targetPage instanceof PageModel) {
Expand Down
26 changes: 12 additions & 14 deletions src/Gateway/GatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ interface GatewayInterface
public function getName(): string;

/**
* In this method, Gateways are expected to seal the
* parcel in such a way, that there is no dynamic data anymore
* when actually sending (@throws CouldNotSealParcelException If the parcel cannot be finalized due to e.g. wrong/missing stamps, content etc.
* In this method, Gateways are expected to seal the parcel in such a way, that
* there is no dynamic data anymore when actually sending (@throws
* CouldNotSealParcelException If the parcel cannot be finalized due to e.g.
* wrong/missing stamps, content etc.
*
*@see sendParcel) the parcel.
* At this stage you should:.
Expand All @@ -24,22 +25,19 @@ public function getName(): string;
* - Add stamps required to actually send the parcel
* - etc.
*
* If you imagine a post office, here's where you actually
* replace all the placeholders on your address label,
* wrap and seal it, and it's ready to go. After that,
* the parcel is considered immutable.
* If you imagine a post office, here's where you actually replace all the
* placeholders on your address label, wrap and seal it, and it's ready to go.
* After that, the parcel is considered immutable.
*/
public function sealParcel(Parcel $parcel): Parcel;

/**
* In this method, Gateways receive the finalized
* parcel. It should be treated immutable at this stage.
* Noting in this method should be dependent from the outside.
* E.g. do not depend on something like the current request etc.
* Only use data from the parcel, nothing else.
* In this method, Gateways receive the finalized parcel. It should be treated
* immutable at this stage. Noting in this method should be dependent from the
* outside. E.g. do not depend on something like the current request etc. Only use
* data from the parcel, nothing else.
*
* This method MUST NOT throw an exception. It is expected to
* always return a receipt.
* This method MUST NOT throw an exception. It is expected to always return a receipt.
*/
public function sendParcel(Parcel $parcel): Receipt;
}
12 changes: 7 additions & 5 deletions src/NotificationCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ public function createParcelForMessage(int $id, StampCollection $stamps): Parcel
}

/**
* If you want to give third-party developers the chance to add stamps or modify your parcel using the
* CreateParcelEvent event, you can manually do so by calling this method. Note that the event also allows
* developers to disable delivery (e.g. based on day time, message settings, conditions etc.). In such a case,
* this method will return null.
* If you want to give third-party developers the chance to add stamps or modify
* your parcel using the CreateParcelEvent event, you can manually do so by
* calling this method. Note that the event also allows developers to disable
* delivery (e.g. based on day time, message settings, conditions etc.). In such a
* case, this method will return null.
*/
public function dispatchCreateParcelEvent(Parcel $parcel): Parcel|null
{
Expand All @@ -232,7 +233,8 @@ public function dispatchCreateParcelEvent(Parcel $parcel): Parcel|null
}

/**
* Checks for a GatewayConfigStamp on the parcel and returns the matching gateway if present.
* Checks for a GatewayConfigStamp on the parcel and returns the matching gateway
* if present.
*/
public function getGatewayForParcel(Parcel $parcel): GatewayInterface|null
{
Expand Down
6 changes: 3 additions & 3 deletions src/Parcel/Parcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public function toArray(): array
}

/**
* Will return an instance of the parcel as it was before it was sealed.
* This means, the stamps that were added AFTER a parcel was sealed will not
* be present on the new instance.
* Will return an instance of the parcel as it was before it was sealed. This
* means, the stamps that were added AFTER a parcel was sealed will not be present
* on the new instance.
*/
public function unseal(): self
{
Expand Down
28 changes: 15 additions & 13 deletions src/Token/Definition/TokenDefinitionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,33 @@ interface TokenDefinitionInterface
{
/**
* Returns the token name for this definition which the user can use in the
* interface using simple tokens.
* E.g. "form_email".
* interface using simple tokens. E.g. "form_email".
*/
public function getTokenName(): string;

/**
* Every token definition can have a description coming from the translation domain
* "contao_nc_tokens". The translation key here is prefixed with "nc_tokens." so
* if you return e.g. "form.foobar" here, the Notification Center will search for
* the translation key "nc_tokens.form.foobar" in the "contao_nc_tokens" domain.
* Every token definition can have a description coming from the translation
* domain "contao_nc_tokens". The translation key here is prefixed with
* "nc_tokens." so if you return e.g. "form.foobar" here, the Notification Center
* will search for the translation key "nc_tokens.form.foobar" in the
* "contao_nc_tokens" domain.
*/
public function getTranslationKey(): string;

/**
* Should return true if the token definition is responsible for a given token name and value.
* Normally this is "$tokenName === $this->getTokenName()" or if the token name ends with "_*" a regex matching
* on this placeholder. But anything is doable in this method. Maybe your definition is responsible for only tokens
* with a given prefix?
* Should return true if the token definition is responsible for a given token
* name and value. Normally this is "$tokenName === $this->getTokenName()" or if
* the token name ends with "_*" a regex matching on this placeholder. But
* anything is doable in this method. Maybe your definition is responsible for
* only tokens with a given prefix?
*/
public function matches(string $tokenName, mixed $value): bool;

/**
* This method is responsible for actually creating a concrete token (NOT the definition) from a
* name and a value. E.g. turning "form_email" and "foobar@example.com" into a Token instance.
* Use this method to e.g. convert object values into your own parsed variant of it.
* This method is responsible for actually creating a concrete token (NOT the
* definition) from a name and a value. E.g. turning "form_email" and
* "foobar@example.com" into a Token instance. Use this method to e.g. convert
* object values into your own parsed variant of it.
*/
public function createToken(string $tokenName, mixed $value, StampCollection|null $stamps = null): Token;
}
5 changes: 3 additions & 2 deletions src/Util/FileUploadNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public function __construct(
}

/**
* This service helps to normalize file upload widget values. Some return an array, others just uuids, some only file
* paths. This method is designed to bring them all to the Contao FormUpload value style.
* This service helps to normalize file upload widget values. Some return an
* array, others just uuids, some only file paths. This method is designed to
* bring them all to the Contao FormUpload value style.
*
* @return array<string, array<array{name: string, type: string, tmp_name: string, error: int, size: int, uploaded: bool, uuid: ?string, stream: ?resource}>>
*/
Expand Down

0 comments on commit f54814a

Please sign in to comment.