Moduleversiondependencies(模块版本依赖性)
Magento平台客户端在升级Magento安装时需要有关已安装扩展和自定义项的重大更改的通知。
为了达到这一目的,所有的第三方插件都需要遵循以下规则:
1.你必须在你模块的composer.json文件的require区域列出该模块所依赖的所有模块列表
2.不要指定对元数据的依赖(例如‘product-community-edition’)
3.如果你使用了一个模块的公共API,指定该模块的MAJOR版本
4.如果你使用了一个模块的任意自定义点,请指定该模块的MAJOR和MINOR版本号。
5.如果你调用或者定制了一个模块的私有代码,请指定该模块的MAJOR,MINOR,和布丁版本。
服务提供商接口
Magento中的PHP接口可以由核心产品和扩展开发人员以多种方式使用。
作为API。 接口由PHP代码调用。
作为服务提供商接口(SPI)。 可以实现一个接口,从而允许代码为平台提供功能。
既。 例如,在服务合同中,我们希望对模块的所有调用都可以通过接口(API)完成,但是我们也支持第三方提供备用实现(SPI)。 API和SPI并不互斥。 因此,我们不会分别区分它们。 SPI的注释与API相同。
但是,依赖关系规则不同:
如果模块使用(调用)API,则它应依赖于MAJOR版本,并且系统在当前主要版本的范围内提供向后兼容性。
API 依赖性示例
```json{
...
"require": {
"magento/customer": "~2.0",
},
...
}
```
如果模块实现API / SPI,则它应依赖于MAJOR + MINOR版本,并且系统在当前次要版本的范围内提供向后兼容性。
SPI依赖性示例:
12
3
4
5
6
7
{ ...
"require": {
"magento/customer": "~2.0.0",
},
...
}
确定模块依赖性
下表列出了API /自定义点的常见用例以及每个用例的版本依赖性。 使用此表可根据您使用模块的API /自定义点的方式在模块上设置适当的版本依赖性。
PHP Interface (marked with @api
)
Inject in a constructor and/or call methods
MAJOR
Implement the interface
MINOR
Re-define the interface preference in di.xml
MINOR
Add a plugin to the interface
MAJOR
Catching method exception
MAJOR
PHP Class (marked with @api
)
Inject in a constructor
MAJOR
Extend from an abstract class
MAJOR
Add a plugin to the class
MAJOR
Configure class preference in di.xml
MAJOR
Configure constructor argument in di.xml
MAJOR
Use class constant
MAJOR
Catching method exception
MAJOR
PHP Class (NOT marked with @api
)
Inject in a constructor
PATCH
Extend from an abstract class
PATCH
Configure class preference in di.xml
PATCH
Configure constructor argument in di.xml
PATCH
Use class constant
PATCH
Catching method exception
PATCH
JavaScript Interface (marked with @api
)
Inject in a constructor and/or call methods
MAJOR
Implement the interface
MINOR
JavaScript class (marked with @api
)
Inject in a constructor
MAJOR
Extend from a class
MINOR
Override a method
MINOR
Subscribe to an event
MINOR
Virtual Type (marked with @api
)
Use an existing virtual type in the di.xml
file as a class dependency
MAJOR
URL Paths
Link to a URL from custom pages
MAJOR
Console commands and their arguments
Called in custom shell scripts
MAJOR
Less variables and mixins
Use in Less declarations
MAJOR
Message queue topics and data types
Consume a topic/message
MINOR
Publish an existing topic
MAJOR
Layout handles declared by modules
Instance blocks added
MAJOR
Blocks and containers moved/removed
MAJOR
Static and dynamic events triggered by a component
Subscribing to event
MAJOR
XML configuration type
Provide another configuration to the configuration type
MAJOR
Extend existing XSD
MINOR
Structure of System Configuration fields used by module
Configure module through System Configuration values
MAJOR
Read system configuration using config path
MAJOR
Database structure
Read/write to a table
MAJOR
Add a column to a table
MINOR
Declare a foreign key on a module table
MAJOR
Declare a trigger on a module table
MAJOR
Read from table or write to table from a temporary table
PATCH
Static view files (marked with @api
)
Rely on JS/CSS/LESS files provided by another module
MAJOR
以上是 Moduleversiondependencies(模块版本依赖性) 的全部内容, 来源链接: utcz.com/z/512370.html