mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-02 17:59:36 +07:00
Drop misleading traces of app.php recommendations
The app init docs still recommended using app.php. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
@@ -19,44 +19,16 @@ Navigation entries for apps can be created by adding a navigation section to the
|
||||
</navigation>
|
||||
|
||||
|
||||
Further pre-app configuration
|
||||
-----------------------------
|
||||
|
||||
The :file:`appinfo/app.php` is the first file that is loaded and executed in Nextcloud. Depending on the purpose of the app it is usually used to setup things that need to be available on every request to the server, like :doc:`backgroundjobs` and :doc:`hooks` registrations. This is how an example :file:`appinfo/app.php` could look like:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
|
||||
// execute OCA\MyApp\BackgroundJob\Task::run when cron is called
|
||||
\OC::$server->getJobList()->add('OCA\MyApp\BackgroundJob\Task');
|
||||
|
||||
// execute OCA\MyApp\Hooks\User::deleteUser before a user is being deleted
|
||||
\OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\MyApp\Hooks\User', 'deleteUser');
|
||||
|
||||
|
||||
Initialization events
|
||||
---------------------
|
||||
|
||||
Often apps do not need to load their JavaScript and CSS on every page. For this
|
||||
purpose there are several events emitted that an app can act upon.
|
||||
|
||||
* `OCA\Files::loadAdditionalScripts` (string): loaded on the files list page
|
||||
* `OCA\Files_Sharing::loadAdditionalScripts` (string): loaded on the public sharing page
|
||||
* `OCA\Files_Sharing::loadAdditionalScripts::publicShareAuth` (string): loaded on the public share authentication page
|
||||
* `OCP\AppFramework\Http\TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS` (constant): loaded when a template response is finished
|
||||
* `OCP\AppFramework\Http\TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN` (constant): loaded when a template response is finished for a logged in user
|
||||
* ``OCA\Files::loadAdditionalScripts`` (string): loaded on the files list page
|
||||
* ``OCA\Files_Sharing::loadAdditionalScripts`` (string): loaded on the public sharing page
|
||||
* ``OCA\Files_Sharing::loadAdditionalScripts::publicShareAuth`` (string): loaded on the public share authentication page
|
||||
* ``OCP\AppFramework\Http\TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS`` (constant): loaded when a template response is finished
|
||||
* ``OCP\AppFramework\Http\TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN`` (constant): loaded when a template response is finished for a logged in user
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
|
||||
$dispatcher = \OC::$server->getEventDispatcher();
|
||||
|
||||
$dispatcher->addListener(
|
||||
OCP\AppFramework\Http\TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
||||
function() {
|
||||
\OCP\Util::addScript('myapp', 'script');
|
||||
\OCP\Util::addStyle('myapp', 'style');
|
||||
}
|
||||
);
|
||||
You can subscribe listeners to these events in the :ref:`bootstrapping code<Bootstrapping>` of the app. See the :ref:`events documentation<Events>` for more details on the event dispatcher and available events.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
.. _Events:
|
||||
|
||||
======
|
||||
Events
|
||||
======
|
||||
|
||||
Reference in New Issue
Block a user