Add 'plugi-core/' from commit '6c478c54d048ab2fd5af4e8e79074153fb594c16'

git-subtree-dir: plugi-core
git-subtree-mainline: d4c734cdbd
git-subtree-split: 6c478c54d0
This commit is contained in:
Paul Spenke
2023-06-13 07:27:11 +08:00
151 changed files with 46689 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace Plugi\Contracts;
interface AuthContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $action
*/
public function handleRequest($action);
/**
* Return whether the current request has an authenticated session.
*
* @return bool
*/
public function isAuthenticated();
/**
* If the current user is not authenticated, show the login form.
*/
public function requireAuth();
/**
* Render the login form.
*/
public function renderLoginForm();
}
@@ -0,0 +1,48 @@
<?php
namespace Plugi\Contracts;
interface CacheContract
{
/**
* Return the cached page content for the given relative URL.
*
* @param string $relativeUrl
* @return string|null
*/
public function getForUrl(string $relativeUrl);
/**
* Store the given page content for the given relative URL.
*
* @param string $relativeUrl
* @param string $pageContent
* @param int $cacheLifetime
*/
public function storeForUrl(string $relativeUrl, string $pageContent, int $cacheLifetime);
/**
* Return the cache storage path for the given relative URL.
*
* @param string $relativeUrl
* @param bool $returnRelative
* @return string
*/
public function getPathForUrl(string $relativeUrl, bool $returnRelative = false): string;
/**
* Analyse the given cache path to determine whether it can be to used, without server/disk space issues.
* This prevents deep nested cache paths and large numbers of cached pages per path due to query string variations.
*
* @param string $cachePath
* @return bool
*/
public function cachePathCanBeUsed(string $cachePath): bool;
/**
* Invalidate all variants stored for the given page route (i.e an URL with * and {} placeholders).
*
* @param string $route
*/
public function invalidate(string $route);
}
@@ -0,0 +1,29 @@
<?php
namespace Plugi\Contracts;
interface MenuRepositoryContract
{
/**
* Replace all menus by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateMenus(array $data);
/**
* Get one hydrated menu with the given name.
*
* @param string $name
* @return object|null
*/
public function getHydratedMenu(string $name);
/**
* Get all hydrated menus with the given name.
*
* @return array
*/
public function getHydratedMenus();
}
@@ -0,0 +1,64 @@
<?php
namespace Plugi\Contracts;
interface PageBuilderContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $route
* @param $action
* @param PageContract|null $page
*/
public function handleRequest($route, $action, PageContract $page = null);
/**
* Render the given page inside the PageBuilder.
*
* @param PageContract $page
*/
public function renderPageBuilder(PageContract $page);
/**
* Render the given page.
*
* @param PageContract $page
* @param null $language
* @return string
*/
public function renderPage(PageContract $page, $language = null): string;
/**
* Update the given page with the given data (an array of html blocks)
*
* @param PageContract $page
* @param $data
* @return bool|object|null
*/
public function updatePage(PageContract $page, $data);
/**
* Get or set custom css for customizing layout of the page builder.
*
* @param string|null $css
* @return string
*/
public function customStyle(string $css = null);
/**
* Get or set custom scripts for customizing behaviour of the page builder.
*
* @param string $location head|body
* @param string|null $scripts
* @return string
*/
public function customScripts(string $location, string $scripts = null);
/**
* Set a theme for the page builder.
*
* @param ThemeContract $theme
*/
public function setTheme(ThemeContract $theme);
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace Plugi\Contracts;
interface PageContract
{
/**
* Set the data stored for this page.
*
* @param array|null $data
* @param bool $fullOverwrite whether to fully overwrite or extend existing data
*/
public function setData($data, $fullOverwrite = true);
/**
* Set the translation data of this page.
*
* @param array|null $translationData
*/
public function setTranslations($translationData);
/**
* Return all data stored for this page (page builder data and other data set via setData).
*
* @return array|null
*/
public function getData();
/**
* Return the page builder data stored for this page.
*
* @return array|null
*/
public function getBuilderData();
/**
* Return the id of this page.
*
* @return string
*/
public function getId();
/**
* Return the layout (file name) of this page.
*
* @return string
*/
public function getLayout();
/**
* Return the name of this page.
*
* @return string
*/
public function getName();
/**
* Return the given language dependant setting for this page, in the current or in the given language.
*
* @param string $setting
* @param string|null $locale
* @return mixed|string|null
*/
public function getTranslation(string $setting, $locale = null);
/**
* Return the translated settings of this page.
*
* @return array
*/
public function getTranslations();
/**
* Return the route of this page, in the current or in the given language.
*
* @param string|null $locale
* @return mixed
*/
public function getRoute($locale = null);
/**
* Get the value of the given property of this Page.
*
* @param $property
* @return mixed|null
*/
public function get($property);
/**
* Invalidate all cached variants of this page.
*/
public function invalidateCache();
}
@@ -0,0 +1,23 @@
<?php
namespace Plugi\Contracts;
interface PageRepositoryContract
{
/**
* Create a new page.
*
* @param array $data
* @return bool|object
*/
public function create(array $data);
/**
* Update the given page with the given updated data.
*
* @param $page
* @param array $data
* @return bool|object|null
*/
public function update($page, array $data);
}
@@ -0,0 +1,13 @@
<?php
namespace Plugi\Contracts;
interface PageTranslationContract
{
/**
* Return the page this translation belongs to.
*
* @return PageContract
*/
public function getPage();
}
@@ -0,0 +1,7 @@
<?php
namespace Plugi\Contracts;
interface PageTranslationRepositoryContract
{
}
@@ -0,0 +1,41 @@
<?php
namespace Plugi\Contracts;
interface RouterContract
{
/**
* Return the page corresponding to the given URL.
*
* @param $url
* @return PageTranslationContract|null
*/
public function resolve($url);
/**
* Return the full page translation instance based on the given matched route or page translation id.
* (this method is helpful when extending a router to perform additional checks after a route has been matched)
*
* @param string $matchedRoute the matched route
* @param string $matchedPageTranslationId the page translation id corresponding to the matched route
* @return PageTranslationContract|null
*/
public function getMatchedPage(string $matchedRoute, string $matchedPageTranslationId);
/**
* Order the given routes into the order in which they need to be evaluated.
*
* @param $allRoutes
* @return array
*/
public function getRoutesInOrder($allRoutes);
/**
* Compare two given routes and return -1,0,1 indicating which route should be evaluated first.
*
* @param $route1
* @param $route2
* @return int
*/
public function routeOrderComparison($route1, $route2);
}
@@ -0,0 +1,23 @@
<?php
namespace Plugi\Contracts;
interface SettingContract
{
/**
* Return the value(s) of the given setting.
*
* @param string $key
* @return mixed|null
*/
public static function get(string $key);
/**
* Return whether the given setting exists and has the given value.
*
* @param string $key
* @param string $value
* @return bool
*/
public static function has(string $key, string $value);
}
@@ -0,0 +1,14 @@
<?php
namespace Plugi\Contracts;
interface SettingRepositoryContract
{
/**
* Replace all website settings by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateSettings(array $data);
}
@@ -0,0 +1,27 @@
<?php
namespace Plugi\Contracts;
interface ThemeContract
{
/**
* Return all blocks of this theme.
*
* @return array array of ThemeBlock instances
*/
public function getThemeBlocks();
/**
* Return all layouts of this theme.
*
* @return array array of ThemeLayout instances
*/
public function getThemeLayouts();
/**
* Return the folder of this theme.
*
* @return mixed
*/
public function getFolder();
}
@@ -0,0 +1,36 @@
<?php
namespace Plugi\Contracts;
interface WebsiteManagerContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $route
* @param $action
*/
public function handleRequest($route, $action);
/**
* Render the website manager overview page.
*/
public function renderOverview();
/**
* Render the website manager page settings (add/edit page form).
*
* @param PageContract $page
*/
public function renderPageSettings(PageContract $page = null);
/**
* Render the website manager menu settings (add/edit menu form).
*/
public function renderMenuSettings();
/**
* Render the welcome page.
*/
public function renderWelcomePage();
}