Skip to content

Commit

Permalink
Merge pull request #2773 from zikula/extensionmodule-refactor
Browse files Browse the repository at this point in the history
Refactor ExtensionsModule to Core-2.0 (except Plugin handling).
  • Loading branch information
craigh committed Mar 2, 2016
2 parents 2a18094 + 26f0d2e commit 5ec5606
Show file tree
Hide file tree
Showing 196 changed files with 5,530 additions and 3,213 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG-1.4.md
Expand Up @@ -14,6 +14,9 @@ CHANGELOG - ZIKULA 1.4.x
- "Alternate Site View" feature (in theme settings) is deprecated. Use responsive design.
- Zikula\Core\AbstractTheme is deprecated and aliased to Zikula\ThemeModule\AbstractTheme. Use the latter.
- Zikula\Core\Theme\Annotation\Theme is deprecated and aliased to Zikula\ThemeModule\Engine\Annotation\Theme. Use the latter.
- All Hooks-related classes and files have been moved to HookBundle and former namespaces deprecated (aliases provided for BC).
- `DisplayHookResponse` has deprecated the third argument and now expects a rendered string instead of objects. (#2600)
- The visibility of ModuleStateEvent::modinfo property will change from public to private in Core-2.0. Use getModInfo() method instead.
- Fixes:
- Fix module stylesheet not being loaded automatically for Core-2.0 modules.
- Fix SearchModule not working for older modules required tables.php (#2643)
Expand All @@ -31,6 +34,7 @@ CHANGELOG - ZIKULA 1.4.x
- Fix structure of `categorizable` key in version spec.
- use `"categorizable": {"entities": ["Acme\FooModule\Entity\FooEntity", "Acme\FooModule\Entity\BarEntity"]}`
- BC with previous method maintained but deprecated, e.g. `"categorizable": ["Acme\FooModule\Entity\FooEntity", "Acme\FooModule\Entity\BarEntity"]`
- Fix issues with dynamic url settings in ExtensionsModule
- Features:
- Add new advanced block filtering based on a combination of any query parameter or request attributes.
- Add core routing for all legacy urls (both normal and 'shorturls').
Expand All @@ -41,6 +45,7 @@ CHANGELOG - ZIKULA 1.4.x
- Add collapseable blocks. This feature had disappeared since Core-1.3x (#2678)
- Add Twig tag `modAvailable($moduleName)` (#2769)
- Add CsrfTokenHandler service (`\Zikula\Core\Token\CsrfTokenHandler`)
- Add 'info' type flash messages.
- Core-2.0 Features:
- Add `currentUser` global variable to twig templates.
- Add (move) `Zikula\CategoriesModule\Entity\AbstractCategoryAssignment` and related documentation.
Expand All @@ -51,14 +56,17 @@ CHANGELOG - ZIKULA 1.4.x
- Zikula\BlocksModule\BlockHandlerInterface
- Zikula\BlocksModule\AbstractBlockHandler
- Updated BlocksModule Admin UI.
- BlocksModule updated to Core-2.0 Spec.
- BlocksModule updated to Core-2.0 Spec.
- ThemeModule updated to Core-2.0 Spec.
- ExtensionsModule updated to Core-2.0 Spec (except Plugin Handling).
- Add AbstractExtensionInstaller for use by third-party developers.
- Add ExtensionVariablesTrait for developers to insert into classes where Extension Variable management is needed.
- Update Pending Content logic and definitions.
- Classes from Zikula\Core\Theme have been moved to Zikula\ThemeModule\Engine.
- Listener classes from Zikula\Bundle\CoreBundle\EventListener\Theme have been moved to Zikula\ThemeModule\EventListener.
- Add Zikula\Common\Translator\TranslatorInterface to use as typehint when using `translator.default` service.
- Add CapabilityApi to manage and define Extension Capabilities for Core-2.0 applications.
- Update `\Zikula\Bundle\HookBundle\Hook\DisplayHookResponse` to allow response from non-Smarty sources. (#2600)
- Vendor updates:
- Symfony updated to 2.8.3
- Font-Awesome updated to 4.5.0
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -9,8 +9,7 @@
"psr-0": {
"Zikula\\": "src/lib",
"Zikula_": "src/lib/legacy",
"DoctrineExtensions\\StandardFields\\": "src/lib/legacy",
"CustomBundle\\": "src/app/custom"
"DoctrineExtensions\\StandardFields\\": "src/lib/legacy"
},
"psr-4": {
"Zikula\\": ["src/system", "src/themes"]
Expand Down Expand Up @@ -46,6 +45,7 @@
"symfony/monolog-bundle": "2.7.*",
"sensio/distribution-bundle": "5.0.*",
"sensio/framework-extra-bundle": "3.0.*",
"sensio/generator-bundle": "3.0.*",
"elao/web-profiler-extra-bundle" : "dev-master",
"matthiasnoback/symfony-service-definition-validator": "1.2.*",
"matthiasnoback/symfony-console-form": "1.*",
Expand Down
4 changes: 3 additions & 1 deletion src/app/ZikulaKernel.php
Expand Up @@ -33,6 +33,7 @@ public function registerBundles()
new Zikula\Bundle\CoreBundle\CoreBundle(),
new Zikula\Bundle\CoreInstallerBundle\ZikulaCoreInstallerBundle(),
new Zikula\Bundle\FormExtensionBundle\ZikulaFormExtensionBundle(),
new Zikula\Bundle\HookBundle\ZikulaHookBundle(),
new Zikula\Bundle\JQueryBundle\ZikulaJQueryBundle(),
new Zikula\Bundle\JQueryUIBundle\ZikulaJQueryUIBundle(),
new JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),
Expand All @@ -48,7 +49,8 @@ public function registerBundles()
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Elao\WebProfilerExtraBundle\WebProfilerExtraBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Zikula\Bundle\GeneratorBundle\ZikulaGeneratorBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
// $bundles[] = new Zikula\Bundle\GeneratorBundle\ZikulaGeneratorBundle();
}

return $bundles;
Expand Down
4 changes: 2 additions & 2 deletions src/app/config/config.yml
Expand Up @@ -89,8 +89,8 @@ doctrine:
# hookstorage required in upgrade.php
zikula_hookstorage:
type: annotation
prefix: Zikula\Component\HookDispatcher\Storage\Doctrine\Entity
dir: "%kernel.root_dir%/../lib/Zikula/Component/HookDispatcher/Storage/Doctrine/Entity"
prefix: Zikula\Bundle\HookBundle\Dispatcher\Storage\Doctrine\Entity
dir: "%kernel.root_dir%/../lib/Zikula/Bundle/HookBundle/Dispatcher/Storage/Doctrine/Entity"
alias: ZikulaHookStorage # this one is optional and will default to the name set for the mapping
is_bundle: false
gedmo_translatable:
Expand Down
9 changes: 8 additions & 1 deletion src/app/config/parameters.yml
Expand Up @@ -43,4 +43,11 @@ parameters:
# is recommended when you have access to them on your server, because changing
# the umask is not thread-safe. Set this value to "~" (NULL), to disable support
# for umask.
umask: ~
umask: ~

# multisites configuration does nothing unless the Multisites module is installed and configured properly.
multisites:
enabled: false
mainsiteurl: ~
based_on_domains: ~
protected.systemvars: []
3 changes: 3 additions & 0 deletions src/app/config/routing.yml
@@ -1,6 +1,9 @@
core:
resource: "@CoreBundle/Resources/config/routing.xml"

hook:
resource: "@ZikulaHookBundle/Resources/config/routing.yml"

fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"

Expand Down
5 changes: 0 additions & 5 deletions src/config/config.php
Expand Up @@ -59,8 +59,3 @@
// http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/caching.html#result-cache
$ZConfig['System']['dbcache.cache_result'] = 0; // 1 to enable or 0 to disable.
$ZConfig['System']['dbcache.cache_result_ttl'] = 30; // seconds, 3600 = 1 hour.

// Initialize multisites array
$ZConfig['Multisites'] = array();
$ZConfig['Multisites']['multisites.enabled'] = 0;
$ZConfig['Multisites']['protected.systemvars'] = array();
12 changes: 6 additions & 6 deletions src/docs/Core-1.x/Hooks/zikula_hooks.rst
Expand Up @@ -228,7 +228,7 @@ In the module controllers, you will need to implement the process and or validat
hook types. This can be done as follows (example of a process hook).

$url = new Zikula_ModUrl(....); // describes how to retrieve this object by URL metadata
$hook = new \Zikula\Core\Hook\ProcessHook($id, $url);
$hook = new \Zikula\Bundle\HookBundle\Hook\ProcessHook($id, $url);
$this->notifyHooks()->dispatch('blog.ui_hooks.articles.process_edit', $hook);


Expand Down Expand Up @@ -302,7 +302,7 @@ When displaying a new empty form, we simply trigger a `form_edit` in the templat
When we come to validate a new create form, this means we have received a submit command
in the form. We can then validate our form and then trigger a `validate_edit` hook with

$hook = new \Zikula\Core\Hook\ValidationHook(new Zikula_Hook_ValidationProviders());
$hook = new \Zikula\Bundle\HookBundle\Hook\ValidationHook(new Zikula_Hook_ValidationProviders());
$this->dispatchHooks('...validate_edit', $hook);
$validators = $hook->getValidators();

Expand All @@ -313,7 +313,7 @@ validation errors.

If it's ok simply commit the form data, then trigger a `process_edit` Zikula_ProcessHook with

new \Zikula\Core\Hook\ProcessHook($name, $id, $url);
new \Zikula\Bundle\HookBundle\Hook\ProcessHook($name, $id, $url);

The URL should be an instance of Zikula_ModUrl which describes how to get the newly created object.
For this reason you must determine the ID of the object before you issue a Zikula_ProcessHook.
Expand Down Expand Up @@ -344,7 +344,7 @@ When displaying an edit form, we simply trigger a `form_edit` hook with with
When we come to validate an edit form, this means we have received a submit command
in the form. We can then validate our form and then trigger a `validate_edit` event with

$hook = new \Zikula\Core\Hook\ValidationHook(new Zikula_Hook_ValidationProviders());
$hook = new \Zikula\Bundle\HookBundle\Hook\ValidationHook(new Zikula_Hook_ValidationProviders());
$this->DispatchHooks('...validate_edit', $hook);
$validators = $hook->getValidators();

Expand All @@ -355,7 +355,7 @@ validation errors.

If it's ok simply commit the form data, then trigger a `process_edit` event with

new \Zikula\Core\Hook\ProcessHook($name, $id, $url);
new \Zikula\Bundle\HookBundle\Hook\ProcessHook($name, $id, $url);

If the data is not ok, then simply redisplay the template. The triggered event will pick up
the validation problems automatically as the validation of each handler will persist in
Expand All @@ -377,7 +377,7 @@ action. Ultimately when a controller (that makes use of hooks) deletes an item,
must notify the attached modules to prevent orphaned records. This is done simply by
triggering a hookable event with

new \Zikula\Core\Hook\ProcessHook($name, $id, $url);
new \Zikula\Bundle\HookBundle\Hook\ProcessHook($name, $id, $url);

`form_delete` hooks are displayed in the template with

Expand Down
24 changes: 13 additions & 11 deletions src/docs/Core-1.x/UPGRADE-1.4.0.md
Expand Up @@ -721,10 +721,10 @@ The main changes are:

- Four new Hook objects with no name arg in the constructor:

- `Zikula\Core\Hook\DisplayHook` (was `Zikula_DisplayHook`).
- `Zikula\Core\Hook\FilterHook` (was `Zikula_FilterHook`).
- `Zikula\Core\Hook\ProcessHook` (was `Zikula_ProcessHook`).
- `Zikula\Core\Hook\ValidationHook` (was `Zikula_ValidationHook`).
- `Zikula\Bundle\HookBundle\Hook\DisplayHook` (was `Zikula_DisplayHook`).
- `Zikula\Bundle\HookBundle\Hook\FilterHook` (was `Zikula_FilterHook`).
- `Zikula\Bundle\HookBundle\Hook\ProcessHook` (was `Zikula_ProcessHook`).
- `Zikula\Bundle\HookBundle\Hook\ValidationHook` (was `Zikula_ValidationHook`).

- hooks are triggered by `->dispatch($name, $hook)` instead of `->notify($hook)`

Expand All @@ -737,17 +737,19 @@ $eventManager->notify($hook);

Example in Core 1.4.0+

$hook = new Zikula\Core\Hook\DisplayHook($id, $url);
$hook = new Zikula\Bundle\HookBundle\Hook\DisplayHook($id, $url);
$hookDispatcher->dispatch('hook.name', $hook);

New class list:

- `Zikula\Core\Hook\ValidationProviders` (was `Zikula_Hook_ValidationProviders`).
- `Zikula\Core\Hook\ValidationResponse` (was `Zikula_Hook_ValidationResponse`).
- `Zikula\Core\Hook\DisplayResponse` (was `Zikula_Response_DisplayHook`).
- `Zikula\Core\Hook\AbstractHookListener` (was `Zikula_Hook_AbstractHandler`).
- `Zikula\Component\HookDispatcher\SubscriberBundle` (was `Zikula_HookManager_SubscriberBundle`).
- `Zikula\Component\HookDispatcher\ProviderBundle` (was `Zikula_HookManager_ProviderBundle`).
- `Zikula\Bundle\HookBundle\Hook\ValidationProviders` (was `Zikula_Hook_ValidationProviders`).
- `Zikula\Bundle\HookBundle\Hook\ValidationResponse` (was `Zikula_Hook_ValidationResponse`).
- `Zikula\Bundle\HookBundle\Hook\DisplayResponse` (was `Zikula_Response_DisplayHook`).
- `Zikula\Bundle\HookBundle\Hook\AbstractHookListener` (was `Zikula_Hook_AbstractHandler`).
- `Zikula\Bundle\HookBundle\Bundle\SubscriberBundle` (was `Zikula_HookManager_SubscriberBundle`).
- `Zikula\Bundle\HookBundle\Bundle\ProviderBundle` (was `Zikula_HookManager_ProviderBundle`).

Notice: in Core-1.4.2 these classes changed again (class aliases are provided for BC):


<a name="modurl" />
Expand Down
34 changes: 10 additions & 24 deletions src/docs/Core-2.0/Hooks/HookContainer.md
Expand Up @@ -2,7 +2,7 @@ HookContainer
=============

Extensions that wish to utilize Hooks must define a HookContainer class that extends
`\Zikula\Component\HookDispatcher\AbstractContainer`. The class must implement one method `setupHookBundles()` which
`\Zikula\Bundle\HookBundle\AbstractHookContainer`. The class must implement one method `setupHookBundles()` which
instantiates and registers hook bundles.

````php
Expand All @@ -20,32 +20,18 @@ See `src/docs/en/dev/Hooks` for more information on Hooks.
Installation of Hooks
---------------------

In the extension's `install` method, the extension must obtain an instance of its own hook container and register
the bundles:
In the extension's `install` method, the extension must utilize the HookApi like so:

```php
$hookContainer = $this->hookApi->getHookContainerInstance($this->bundle->getMetaData());
\HookUtil::registerSubscriberBundles($hookContainer->getHookSubscriberBundles());
$this->hookApi->installSubscriberHooks($this->bundle->getMetaData());
// and|or
$this->hookApi->installProviderHooks($this->bundle->getMetaData());
```

In the `uninstall` method, the extension must do the same (except use `unregister...`):
In the `uninstall` method, the extension must implement:

```php
$hookContainer = $this->hookApi->getHookContainerInstance($this->bundle->getMetaData());
\HookUtil::unregisterSubscriberBundles($hookContainer->getHookSubscriberBundles());
```

All the extensions hooks can be stored in the same container and simply defined as either Provider or Subscriber bundles.
If you wish, you may separate the definition bundles by defining different classes in the composer file. If the
HookContainers are separate for each type, then you must specify the type in the instantiation:

```php
$subscriberHookContainer = $this->hookApi->getHookContainerInstance($this->bundle->getMetaData(), HookApi::SUBSCRIBER_TYPE);
\HookUtil::registerSubscriberBundles($subscriberHookContainer->getHookSubscriberBundles());

$providerHookContainer = $this->hookApi->getHookContainerInstance($this->bundle->getMetaData(), HookApi::PROVIDER_TYPE);
\HookUtil::registerProviderBundles($providerHookContainer->getHookProviderBundles());
```

Please note that install/remove is not 100% finalized for the Core-2.0.0 spec. It is possible that this may eventually
simply be removed altogether and the core will handle installation and removal of an extension's hooks.
$this->hookApi->uninstallSubscriberHooks($this->bundle->getMetaData());
// and|or
$this->hookApi->uninstallProviderHooks($this->bundle->getMetaData());
```
4 changes: 2 additions & 2 deletions src/docs/Core-2.0/Hooks/definitions.md
Expand Up @@ -15,12 +15,12 @@ In order for hooks to function, the `composer.json` file must define the extensi
}
```

Note that this replaces the 1.4.x convention of identifying the capabilities with
Note that this **replaces** the 1.3.x/1.4.x convention of identifying the capabilities with
`"hook_subscriber": {'enabled": true}`.

Only define the key(s) that the module implements (e.g. `"hook_subscriber"` or `"hook_provider"` or both).

It is technically possible to define two different definition classes (one for subscriber and one for provider hooks).
If this is done, you must specify the hook type when instantiating the class from the Api (See HookContainer).

See `src/docs/en/dev/Hooks` for more information on Hooks.
See `src/docs/Core-1.x/Hooks` and `src/docs/Core-1.x/UPGRADE-1.4.0.md` for more information on Hooks.
16 changes: 16 additions & 0 deletions src/docs/Core-2.0/Twig/Filters.md
@@ -0,0 +1,16 @@
Twig Filters Provided by Zikula Core
============+=======================

The following twig filters are available in templates. These are in addition to the standard functions provided
by the Twig package itself. See [Twig Documentation](http://twig.sensiolabs.org/documentation) for more information.

Filters
-------

* isCoreModule
* languageName
* notifyFilters(filterEventName)
* php(func)
* safeHtml
* urldecode
* yesNo
67 changes: 67 additions & 0 deletions src/docs/Core-2.0/Twig/Functions.md
@@ -0,0 +1,67 @@
Twig Functions Provided by Zikula Core
======================================

The following twig functions are available in templates. These are in addition to the standard functions provided
by the Twig package itself. See [Twig Documentation](http://twig.sensiolabs.org/documentation) for more information.

Functions
---------

### Useful

* array_unset(array, key)
* callFunc(callable, params = [])
* defaultPath(extensionName, type = "user")
* getModVar(module, name, default = null)
* hasPermission(component, instance, level)
* modAvailable(modname, force = false)
* pageAddAsset(type, value, weight = 100)
* pageAddVar(name, value)
* pageGetVar(name, default = null)
* pageSetVar(name, value)
* pager(params)
* polyfill(features = ["forms"])
* setMetaTag(name, value)
* showflashes(params = [])
* stateLabel(extensionEntity, upgradedExtensions = null)
* zasset(path)

### Hooks

* notifyDisplayHooks(eventName, id = null, urlObject = null)

### Translation/Language

* __(message, domain = null, locale = null)
* __f(message, params, domain = null, locale = null)
* __fp(context, message, params, domain = null)
* __p(context, message, domain = null)
* _fn(singular, plural, count, params, domain = null, locale = null)
* _fnp(context, singular, plural, count, params, domain = null)
* _n(singular, plural, count, domain = null, locale = null)
* no__(msgid)
* lang(fs = false)
* langdirection()

### System Specific

* adminPanelMenu()
* extensionActions(extension)
* getPreviewImagePath(themeName, size = "medium")

#### Blocks

* positionavailable(name)
* showblock(block, positionName = "")
* showblockposition(positionName, implode = true)

#### Atom Theme

* atomFeedLastUpdated()
* atomId()

### Unimplemented

* button()
* icon()
* img()

0 comments on commit 5ec5606

Please sign in to comment.