-
Notifications
You must be signed in to change notification settings - Fork 42
/
LegacyListener.php
57 lines (51 loc) · 1.76 KB
/
LegacyListener.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2015 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package MetaModels
* @subpackage Core
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
* @copyright 2012-2015 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0
* @filesource
*/
namespace MetaModels\Attribute\Events;
use MetaModels\Attribute\LegacyAttributeTypeFactory;
/**
* This class implements the fallback implementation of the MetaModels Version 1.X attribute factory.
*
* @deprecated You should refactor every attribute to implement an event listener to create new instances.
*/
class LegacyListener
{
/**
* Register all legacy factories and all types defined via the legacy array as a factory.
*
* @param CreateAttributeFactoryEvent $event The event.
*
* @return void
*
* @deprecated This method is part of the backwards compatible layer.
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
public static function registerLegacyAttributeFactoryEvents(CreateAttributeFactoryEvent $event)
{
if (empty($GLOBALS['METAMODELS']['attributes'])) {
return;
}
$factory = $event->getFactory();
foreach ($GLOBALS['METAMODELS']['attributes'] as $typeName => $attributeInformation) {
$typeFactory = LegacyAttributeTypeFactory::createLegacyFactory($typeName, $attributeInformation);
$factory->addTypeFactory($typeFactory);
}
}
}