1
0
mirror of https://github.com/flarum/core.git synced 2025-07-25 02:31:17 +02:00
Commit Graph

90 Commits

Author SHA1 Message Date
Alexander Skvortsov
ea7d31e15e Revert "Use lifecycle interface for frontend extender (#2211)" (#2301)
This reverts commit 368a9836bd.
2020-09-23 00:21:45 -04:00
Alexander Skvortsov
c10ebea00c User Extender (prepareGroups functionality) (#2110) 2020-07-17 12:18:35 +02:00
Franz Liedke
b89ccaf83c Rename view extender
As discussed in my initial review, it seems unlikely that we need
the ability to remove (or otherwise modify) namespaces again.
Therefore, it seems more consistent with other extenders to go
for a "View" extender with a "namespace" method.

Sorry for the back and forth. ;)

Refs #1891, #2134.
2020-07-17 12:05:49 +02:00
Franz Liedke
3b6dbddee9 View extender: Do not resolve factory
Not all requests need this factory, so there is no need to
instantiate one and load the required files.

Refs #1891, #2134.
2020-07-17 12:05:38 +02:00
Alexander Skvortsov
cd58692fca View Extender (add namespace) (#2134) 2020-07-17 11:59:00 +02:00
Alexander Skvortsov
368a9836bd Use lifecycle interface for frontend extender (#2211) 2020-07-17 11:49:52 +02:00
Alexander Skvortsov
417e878c0c Fix: Use proper variable for display name drivers in user extender 2020-06-29 19:32:08 -04:00
Alexander Skvortsov
f7985bac61 Use drivers for display names, add display name extender (#2174)
* Deprecate GetDisplayName event

* Add interface for display name driver

* Add username driver as default

* Add code to register supported drivers / used driver as singletons

* Configured User class to use new driver-based system for display names

* Add extender for adding display name driver

* Add integration test for user display name driver

* Add frontend UI for selecting display name driver
2020-05-19 18:45:56 -04:00
Franz Liedke
56ef8b4613 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-04-24 14:56:37 +00:00
Franz Liedke
4e95b2b719 Clean up model extender
- Remove unused private attributes
- Complete docblocks
- Add scalar type hints
- Format code
- Reorder methods

Refs #2100.
2020-04-24 16:33:08 +02:00
Franz Liedke
6dc362f760 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-04-24 13:10:36 +00:00
Alexander Skvortsov
ef44ff5603 Add model extender (#2100)
This covers default attribute values, date attributes and custom relationships.
2020-04-24 15:10:24 +02:00
Franz Liedke
c1db2b5a45 Format code
- Early returns
- Comments
- Write variables only when needed

Refs #2020.
2020-04-19 16:53:52 +02:00
Robert Korulczyk
9b925a5071 Load only translations for enabled extensions from language packs (#2020)
fix #1837

Co-authored-by: Daniel Klabbers <daniel+git@klabbers.email>
2020-04-19 16:29:45 +02:00
Franz Liedke
8b30734ffb Tweak event extender (tests)
- Inject contract, not implementation
- Do not dispatch event in test, let the core do that
- Ensure the relevant database tables are reset prior to the test
- Use correct parameter order for assertions

Refs #2097.
2020-04-13 11:58:47 +02:00
Franz Liedke
cde69480bf Tweak mail extender (tests)
- Use private over protected
- Use "public" API for building requests in tests
- Add more assertions
- Formatting
- Use correct parameter order for assertions

Refs #2012.
2020-04-13 11:58:46 +02:00
Alexander Skvortsov
0245df0573 Mail Extender (#2012)
This allows registering new drivers, or overwriting existing ones.
2020-04-13 10:46:33 +02:00
Alexander Skvortsov
f0adb6a120 Add event extender (used for domain events) (#2097) 2020-04-13 10:45:34 +02:00
Alexander Skvortsov
d627d01544 Added CSRF Extender (#2095) 2020-04-03 21:32:18 +02:00
Alexander Skvortsov
c84dd4d5bf Add console extender (#2057)
* Made the console command system extender-friendly

* Added console extender

* Added ConsoleTestCase to integration tests

* Added integration tests for console extender

* Marked event-based console extension system as deprecated

* Moved trimming command output of whitespace into superclass

* Renamed 'add' to 'command'

* Added special processing for laravel commands

* Code style fixes

* More style fixes

* Fixed $this->container
2020-04-03 19:38:54 +02:00
Matt Kilgore
b0fd63adc3 Fix test and extender for middleware (#2084) 2020-03-27 11:00:30 +01:00
Matt Kilgore
84dafdd5c3 fix insertAfter and insertBefore middleware extender functions (#2063) 2020-03-20 22:59:57 +01:00
Matt Kilgore
77062dd833 Change Extenders properties to private (#1958) 2020-03-17 22:37:17 +01:00
Franz Liedke
774dd10bf5 Fix typo 2020-03-06 15:05:15 +01:00
Franz Liedke
a1a2b35221 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-03-06 13:55:39 +00:00
Franz Liedke
18ef23cb5f New extender for error handling (#1970)
This extender implements several methods for extending the new error
handling stack implemented in #1843.

Most use-cases should be covered, but I expect some challenges for more
complex setups. We can tackle those once they come up, though. Basic
use-cases should be covered.

Fixes #1781.
2020-01-31 14:01:12 +01:00
Matthew Kilgore
93c6babc61 Additional functionality for Middleware extender
Implements the remove, insertBefore, insertAfter and replace
functionality for middlewares.

The IoC container now holds one array of middleware (bindings) per
frontend stack - the extender operates on that array, before it is
wrapped in a middleware "pipe".

Fixes #1957, closes #1971.
2020-01-24 21:20:33 +01:00
Matt Kilgore
d55daf2a8c Change Zend namespace to Laminas (#1963)
Also ensure backwards compatibility for extensions that use the Zend framework but don't explicitly require it.
2020-01-06 22:29:34 +01:00
Matt Kilgore
441d74f1af Middleware extender (#1952) 2019-12-12 09:22:04 +01:00
Franz Liedke
5020a3a927 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-28 00:16:50 +00:00
Franz Liedke
51b33c8cab Make exception message dynamic as well 2019-08-01 22:25:28 +02:00
Daniël Klabbers
9209a5f588 Allows configuration of where the language files live. So that
language packs can optionally decide for themselves if they want
to use a different directory.
2019-07-31 17:10:13 +02:00
Franz Liedke
e27cd69974 Allow passing strings (names of invokable classes) to Formatter extender
In preparation for fixing #1703.
2018-12-15 12:05:17 +01:00
Franz Liedke
d97f7136df Inject dependencies when firing events, not before
The event subscriber approach means that dependencies have to be
injected (and thus instantiated, along with all *their* dependencies) at
the time of registering event listeners - even when events are never
fired within a request's lifecycle.

This is unnecessary and causes more classes than necessary to be loaded.

In this case, we can explicitly register event listeners that will
resolve their dependencies when the event is fired, not before.

Refs #1578.
2018-12-13 02:01:50 +01:00
Franz Liedke
25c8ab0a35 Do not resolve services when extending them
Refs #1578.
2018-12-13 01:58:54 +01:00
Toby Zerner
13ce2d1e3d Performance: Actually make use of the translator cache
We had added a `storage/locale` directory to our skeleton, but we had
forgotten to hook it up with the translator. Enabling caching saves
parsing that locale YAML files on every pageload which should be good
for performance.

The locale cache will be cleared whenever an extension that uses the
`Locales` or `LanguagePack` extenders is enabled/disabled. If debug
mode is ON, then the caching mechanism will automatically check if any
of the loaded YAML files are dirty and update accordingly.
2018-12-07 09:38:08 +10:30
David Sevilla Martín
bd210636e8 Fix frontend extender using old container & wrong class 2018-11-22 21:17:32 +01:00
Toby Zerner
171f9184d9 Refactor frontend code to allow for extension of assets
- Simpler class naming:
    Frontend\CompilerFactory → Frontend\Assets
    Frontend\HtmlDocumentFactory → Frontend\Frontend
    Frontend\HtmlDocument → Frontend\Document

- Remove AssetInterface and simply collect callbacks in Frontend\Assets
  instead

- Remove ContentInterface because it serves no purpose (never type-
  hinted or type-checked)

- Commit and add asset URLs to the Document via a content callback
  instead of in the Document factory class itself

- Add translations and locale assets to Assets separate to the assets
  factory, as non-forum/admin asset bundles probably won't want them

- Update Frontend Extender to allow the creation of new asset bundles

- Make custom LESS validation listener a standalone class instead of
  extending RecompileFrontendAssets
2018-11-22 12:09:50 +10:30
Toby Zerner
7250e28700 Typehint Frontend extender arguments 2018-11-16 15:19:51 +10:30
Franz Liedke
cbe52ff846 New extender for adding variables to HtmlDocument payload
Fixes #1602.
2018-10-21 20:45:19 +02:00
Franz Liedke
5704c37c18 Add a new extender interface for extension lifecycle hooks 2018-09-26 22:56:25 +02:00
Franz Liedke
2bf6a25230 Tweak extender interface in preparation for adding more methods 2018-09-26 22:36:36 +02:00
Toby Zerner
52b5bdcf4e Revert "Frontend extender: Remove route registration"
This reverts commit df6f10da20.
2018-09-21 09:05:45 +09:30
Franz Liedke
df6f10da20 Frontend extender: Remove route registration
This can be achieved using the Route extender, which is more
flexible, as it does not necessary connect the URL with the current
frontend's router.

(Example use-case: The ext-embed frontend will be a new frontend,
however any routes using this frontend will be part of the forum
route group.)

Refs #851.
2018-09-07 01:40:31 +02:00
Franz Liedke
c53ec59d56 Frontend extender: Route to correct frontend
So far, we always added routes configured via this extender to the
forum frontend. Not correct.
2018-09-07 01:02:13 +02:00
Franz Liedke
e8c779fcf4 Frontend extender: Work without extension, too 2018-09-01 16:15:02 +02:00
Franz Liedke
10d39cb06d Apply fixes from StyleCI (#1518)
[ci skip] [skip ci]
2018-07-23 16:25:12 +02:00
Franz Liedke
a0741f801b Replace Assets with Frontend extender
This extender allows registering both assets and simple GET routes
with frontend instances.

See #851.
2018-07-23 16:24:00 +02:00
Toby Zerner
651a6bf4ea Frontend refactor (#1471)
Refactor Frontend + Asset code

- Use Laravel's Filesystem component for asset IO, meaning theoretically
  assets should be storable on S3 etc.

- More reliable checking for asset recompilation when debug mode is on,
  so you don't have to constantly delete the compiled assets to force
  a recompile. Should also fix issues with locale JS files being
  recompiled with the same name and cached.

- Remove JavaScript minification, because it will be done by Webpack
  (exception is for the TextFormatter JS).

- Add support for JS sourcemaps.

- Separate frontend view and assets completely. This is an important
  distinction because frontend assets are compiled independent of a
  request, whereas putting together a view depends on a request.

- Bind frontend view/asset factory instances to the container (in
  service providers) rather than subclassing. Asset and content
  populators can be added to these factories – these are simply objects
  that populate the asset compilers or the view with information.

- Add RouteHandlerFactory functions that make it easy to hook up a
  frontend controller with a frontend instance ± some content.

- Remove the need for "nojs"

- Fix cache:clear command

- Recompile assets when settings/enabled extensions change
2018-06-30 12:31:12 +09:30
Toby Zerner
d7dd4bf8a0 [WIP] JS Extender API foundation (#1468)
* Run extenders exported by extensions
* Add some basic extenders
* Patch Mithril as the very first thing so extension code can run safely
* Load the payload into the app before booting extensions
* Setup default routes before booting extensions
2018-06-22 10:49:46 +09:30