File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ class Authorization
7777 */
7878 protected $ encryptedSerializedAccessToken ;
7979
80+ /**
81+ * @var string
82+ * @ORM\Column(nullable = true, type = "text")
83+ */
84+ protected $ metadata ;
85+
8086 /**
8187 * @Flow\Transient
8288 * @var EncryptionService
@@ -287,4 +293,14 @@ public function setExpires(\DateTimeImmutable $expires): void
287293 {
288294 $ this ->expires = $ expires ;
289295 }
296+
297+ public function getMetadata (): ?string
298+ {
299+ return $ this ->metadata ;
300+ }
301+
302+ public function setMetadata (string $ metadata ): void
303+ {
304+ $ this ->metadata = $ metadata ;
305+ }
290306}
Original file line number Diff line number Diff line change @@ -483,6 +483,26 @@ public function renderFinishAuthorizationUri(): string
483483 }
484484 }
485485
486+ /**
487+ * Helper method to set metadate on an Authorization instance, makes sure the
488+ * change is persisted.
489+ *
490+ * @param string $authorizationId
491+ * @param string $metadata
492+ * @return void
493+ */
494+ public function setAuthorizationMetadata (string $ authorizationId , string $ metadata ): void
495+ {
496+ $ authorization = $ this ->getAuthorization ($ authorizationId );
497+ if ($ authorization === null ) {
498+ throw new \RuntimeException ('Authorization not found ' , 1631821719 );
499+ }
500+ $ authorization ->setMetadata ($ metadata );
501+
502+ $ this ->entityManager ->persist ($ authorization );
503+ $ this ->entityManager ->flush ();
504+ }
505+
486506 /**
487507 * @param string $clientId
488508 * @param string $clientSecret
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace Neos \Flow \Persistence \Doctrine \Migrations ;
5+
6+ use Doctrine \DBAL \Schema \Schema ;
7+ use Doctrine \Migrations \AbstractMigration ;
8+
9+ /**
10+ * Add metedata column on Authorization table
11+ */
12+ final class Version20210916194112 extends AbstractMigration
13+ {
14+ public function getDescription (): string
15+ {
16+ return 'Add metedata column on Authorization table ' ;
17+ }
18+
19+ public function up (Schema $ schema ): void
20+ {
21+ $ this ->abortIf ($ this ->connection ->getDatabasePlatform ()->getName () !== 'mysql ' , 'Migration can only be executed safely on \'mysql \'. ' );
22+
23+ $ this ->addSql ('ALTER TABLE flownative_oauth2_client_authorization ADD metadata LONGTEXT DEFAULT NULL ' );
24+ }
25+
26+ public function down (Schema $ schema ): void
27+ {
28+ $ this ->abortIf ($ this ->connection ->getDatabasePlatform ()->getName () !== 'mysql ' , 'Migration can only be executed safely on \'mysql \'. ' );
29+
30+ $ this ->addSql ('ALTER TABLE flownative_oauth2_client_authorization DROP metadata ' );
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments