Skip to content

Commit

Permalink
Merge branch 'develop' into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Apr 10, 2024
2 parents 8472a91 + 0142280 commit 275fd24
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
23 changes: 22 additions & 1 deletion src/Database/ExpandoModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public function __construct(array $attributes = [])
$this->addJsonable($this->expandoColumn);
}

/**
* setExpandoAttributes on the model and protects the passthru values
*/
public function setExpandoAttributes(array $attributes = [])
{
$this->attributes = array_merge(
$this->attributes,
array_diff_key($attributes, array_flip($this->getExpandoPassthru()))
);
}

/**
* expandoAfterFetch constructor event
*/
Expand Down Expand Up @@ -72,6 +83,16 @@ public function expandoAfterSave()
*/
protected function getExpandoPassthru()
{
return array_merge([$this->getKeyName(), $this->expandoColumn], $this->expandoPassthru);
$defaults = [
$this->expandoColumn,
$this->getKeyName(),
$this->getCreatedAtColumn(),
$this->getUpdatedAtColumn(),
'site_root_id',
'updated_user_id',
'created_user_id'
];

return array_merge($defaults, $this->expandoPassthru);
}
}
23 changes: 21 additions & 2 deletions src/Support/Facades/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,42 @@
/**
* Site facade
*
* @method static bool hasFeature(string $name)
* @method static mixed getSiteFromRequest(string $host, string $uri)
* @method static mixed getSiteFromId($id)
* @method static mixed getPrimarySite()
* @method static mixed getAnySite()
* @method static bool hasAnySite()
* @method static bool hasMultiSite()
* @method static bool hasSiteGroups()
* @method static array listEnabled()
* @method static array listSiteIds()
* @method static iterable listSites()
* @method static mixed getEditSite()
* @method static string getEditSiteId()
* @method static void setEditSiteId(string $siteId)
* @method static void setEditSite(mixed $site)
* @method static mixed getAnyEditSite()
* @method static bool hasAnyEditSite()
* @method static bool hasMultiEditSite()
* @method static iterable listEditEnabled()
* @method static void applyEditSite(mixed $site)
* @method static mixed getActiveSite()
* @method static string getActiveSiteId()
* @method static void setActiveSiteId(string $siteId)
* @method static void setActiveSite(mixed $site)
* @method static void applyActiveSite(mixed $site)
* @method static array listSiteIdsInGroup($siteId)
* @method static array listSiteIdsInLocale($siteId)
* @method static iterable listSites()
* @method static int|null getSiteIdFromContext()
* @method static string|null getSiteCodeFromContext()
* @method static mixed getSiteFromContext()
* @method static bool hasGlobalContext()
* @method static void withGlobalContext(callable $callback)
* @method static void withContext($siteId, callable $callback)
* @method static bool hasFeature(string $name)
* @method static mixed getSiteFromBrowser(string $acceptLanguage)
* @method static mixed getSiteForLocale(string $locale)
* @method static void resetCache()
*
* @see \System\Classes\SiteManager
*/
Expand Down

0 comments on commit 275fd24

Please sign in to comment.