In my-plugin/my-plugin.php
:
public function onPluginsInitialized(): void {
...
$this->router();
}
public function router() {
/** @var Uri $uri */
In my-plugin/my-plugin.php
:
public function onPluginsInitialized(): void {
...
$this->router();
}
public function router() {
/** @var Uri $uri */
If you've found your way to this article, odds are you're already familiar with Grav CMS.
For the uninitiated, Grav is a Flat-File CMS which instead of using traditional databases like MySQL, Postgres, or MongoDB, Grav primarily uses YAML and Markdown for storing your page data.
That's enough to get the job done for many sites--but if you have data that doesn't really warrant a page and needs to be more dynamic in its creation, storage, and retrieval, Grav pages might feel like you're attempting to smash a square peg in a round hole.
Meet Grav's Flex Objects.
Grav's Flex Objects require Grav version 1.7+
<?php | |
public function onTotalsCalculate() { | |
$storedPassword = $this->config->get('plugins.gravel.webhook_password'); | |
$providedPassword = $this->grav['uri']->param('p'); | |
if ($storedPassword === $providedPassword) { | |
$flex = Grav::instance()['flex']; | |
$reviewsCol = $flex->getCollection('reviews'); | |
$locationsDir = $flex->getDirectory('locations'); | |
$reviewsApproved = $reviewsCol->filterBy(['approved' => true, 'processed' => false]); |
React Hooks are a feature introduced in React version 16.8 that allow you to use state and other React features without writing a class. They are JavaScript functions that let you "hook into" React state and lifecycle features from function components Source 3.
There are two main rules for using hooks in React:
Only call hooks at the top level: Don't call hooks inside loops, conditions, or nested functions. Instead, always use hooks at the top level of your React function, before any return keyword Source 2.
Only call hooks from React function components or custom hooks: You should never call hooks from regular JavaScript functions. However, you can call hooks from React functional components and custom hooks Source 2.
These rules are enforced by the ESLint plugin called `eslint-plugin-react-ho