Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hux-3363433
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
hux-3363433
Commits
5ade7467
Verified
Commit
5ade7467
authored
2 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Update documentation to promote autodiscovery method, demote service definition method
parent
4eb711e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+24
-12
24 additions, 12 deletions
README.md
with
24 additions
and
12 deletions
README.md
+
24
−
12
View file @
5ade7467
...
...
@@ -30,27 +30,21 @@ Other features
# Usage
Add an entry to your modules' services.yml file. The entry simply needs to be a
public service, with a class and the 'hooks' tag.
Create a class in the directory/namespace:
Once a hook class has been added as a service, just clear the site cache.
-
File:
`src/Hooks/MyModuleHooks.php`
-
Namespace:
`Drupal\Hooks\MyModuleHooks`
Tip: You do not need to clear the site cache to add more hook implementations!
Once at least one hook has been added to the class, just clear the site cache.
```
yaml
services
:
my_module.hooks
:
class
:
Drupal\my_module\MyModuleHooks
tags
:
-
{
name
:
hooks
}
```
Tip: You do not need to clear the site cache to add more hook implementations!
And in the class file:
```
php
declare
(
strict_types
=
1
);
namespace
Drupal\my_module
;
namespace
Drupal\my_module
\Hooks
;
use
Drupal\hux\Attribute\Alter
;
use
Drupal\hux\Attribute\Hook
;
...
...
@@ -121,6 +115,24 @@ Working examples of all Hux features can be found in included tests.
# Optional configuration
## Hooks classes outside of Hooks namespace/directory
Hooks will be automatically discovered in the Hooks namespace, however you can
register a class outside this directory by specifying a service.
Add an entry to your modules' services.yml file. The entry simply needs to be a
public service, with a class and the 'hooks' tag.
```
yaml
services
:
my_module.hooks
:
class
:
Drupal\my_module\MyModuleHooks
tags
:
-
{
name
:
hooks
}
```
Then clear the site cache.
## Optimised mode
Hux'
[
optimized mode
][
optimized-mode
]
provides an option geared towards being
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment