-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(copy): added check field relations (which entry type is allowed …
…where)
- Loading branch information
Showing
5 changed files
with
266 additions
and
144 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,46 @@ | ||
<?php | ||
|
||
namespace vandres\matrixextended\services; | ||
|
||
use Craft; | ||
use vandres\matrixextended\MatrixExtended; | ||
|
||
class MatrixService | ||
{ | ||
/** | ||
* Returns a list, which child can have which parent. | ||
* | ||
* e.g. | ||
* ``` | ||
* [ | ||
* 35 => [ | ||
* 18, 4, 51 | ||
* ], | ||
* ... | ||
* ] | ||
* ``` | ||
* | ||
* @return array | ||
*/ | ||
public function getChildParentRelations(): array | ||
{ | ||
$relations = []; | ||
$entryTypes = Craft::$app->getEntries()->getAllEntryTypes(); | ||
|
||
foreach ($entryTypes as $entryType) { | ||
$relations[$entryType->id] = array_map(fn($usage) => $usage->id, $entryType->findUsages()); | ||
} | ||
|
||
return $relations; | ||
} | ||
|
||
public function setReference($reference): void | ||
{ | ||
Craft::$app->getSession()->set('matrixExtendedReference' . MatrixExtended::getInstance()->schemaVersion, $reference); | ||
} | ||
|
||
public function getReference(): ?array | ||
{ | ||
return Craft::$app->getSession()->get('matrixExtendedReference' . MatrixExtended::getInstance()->schemaVersion) ?: null; | ||
} | ||
} |
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
Oops, something went wrong.