Skip to content

Commit

Permalink
Merge pull request #177 from happycog/cache-pofo
Browse files Browse the repository at this point in the history
Use Craft's internal cache of field layouts
  • Loading branch information
engram-design authored Jul 17, 2024
2 parents 9a5526d + 820dcf3 commit 2c43df3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/base/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function scenarios(): array
public function defineRules(): array
{
$rules = parent::defineRules();

// Validation for only when saving Hyper fields and their settings
$rules[] = [['label', 'handle'], 'required', 'on' => [self::SCENARIO_SETTINGS]];

Expand Down Expand Up @@ -324,7 +324,17 @@ public function getFieldLayout(): ?FieldLayout
}

if ($this->layoutUid) {
$this->_fieldLayout = Hyper::$plugin->getService()->getFieldLayoutByUid($this->layoutUid);
$fieldLayout = null;
$layouts = Craft::$app->getFields()->getLayoutsByType(static::class);

foreach ($layouts as $layout) {
if ($layout->uid === $this->layoutUid) {
$fieldLayout = $layout;
break;
}
}

$this->_fieldLayout = $fieldLayout;
}

return $this->_fieldLayout;
Expand Down

0 comments on commit 2c43df3

Please sign in to comment.