定制 micaherne/rector-moodle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

micaherne/rector-moodle

Composer 安装命令:

composer require micaherne/rector-moodle

包简介

Rector config for upgrading Moodle plugins

README 文档

README

This package provides basic rule sets for upgrading Moodle plugins for compatibility with new versions, using Rector.

Note that this is a work in progress and does not provide a comprehensive migration. Manual checking is still necessary.

Install

Rector is installed using Composer, and this package should be installed similarly. Add a development dependency:

composer require --dev micaherne/rector-moodle

Configuration

This library provides a configuration helper class that must be used to configure Rector correctly to understand Moodle classes. This is essential for many Rector rules as they can break your code if they are not aware of the Moodle class hierarchy.

Rule sets can be added to your rector.php config file. For example:

use RectorMoodle\Config\MoodleRectorConfig;
use RectorMoodle\Set\MoodleLevelSetList;

return MoodleRectorConfig::configure('/path/to/your/moodle/root')
    ->withSets([
        MoodleLevelSetList::UP_TO_MOODLE_45
    ])
    ->withImportNames();

The following rule sets are available:

  • MoodleSetList::MOODLE_42 - Update features introduced in Moodle 4.2
  • MoodleSetList::MOODLE_43 - Update features introduced in Moodle 4.3
  • MoodleSetList::MOODLE_44 - Update features introduced in Moodle 4.4
  • MoodleSetList::MOODLE_45 - Update features introduced in Moodle 4.5
  • MoodleSetList::RENAME_CONTEXT_CLASSES - Rename context classes to the new namespaced names introduced in Moodle 4.2, and convert level constants like CONTEXT_COURSE to the corresponding new LEVEL class constant. This is separate from the Moodle 4.2 set as the documentation strongly implies that there is no requirement to update from the old \context_* class names, and that the class aliases for backward compatibility will be retained indefinitely.
  • MoodleLevelSetList::UP_TO_MOODLE_43 - Apply both the Moodle 4.2 and 4.3 updates.
  • MoodleLevelSetList::UP_TO_MOODLE_44 - Apply Moodle 4.2, 4.3 and 4.4 updates.
  • MoodleLevelSetList::UP_TO_MOODLE_45 - Apply Moodle 4.2, 4.3, 4.4 and 4.5 updates.

A note on symbol discovery

Some rules in Rector require knowledge of the class hierarchy or other symbols (e.g. CompleteDynamicPropertiesRector).

For these rules to work correctly, the whole Moodle codebase must be scanned. This appears as if it should be possible by using the autoloadPaths() method on the RectorConfig object, but this does not seem to work as expected.

In addition to this, Rector must be aware of class aliases and the classes they point to. There is no way to do this in PHPStan (which Rector uses for symbol discovery) through configuration, so the aliased classes must be loaded and the aliases created. This means that the MoodleRectorConfig class actually runs some of your Moodle code, so please ensure that you are running this in a safe environment.

Class aliases

Note that the above method of symbol discovery only deals with class aliases in the core Moodle codebase, and if you have any in your own codebase, you will need to ensure that they are available to Rector.

Coverage

The rule sets mainly concentrate on updating class names where these are moved (e.g. as defined in the renamedclasses.php files), or where functions are moved to static methods on classes but retain the same signature.

There are various other changes between Moodle versions but some of these are not possible to implement an automated refactoring for, so this is not a replacement for following the guidance in the Moodle upgrade.txt files.

micaherne/rector-moodle 适用场景与选型建议

micaherne/rector-moodle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 micaherne/rector-moodle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 micaherne/rector-moodle 我们能提供哪些服务?
定制开发 / 二次开发

基于 micaherne/rector-moodle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-03-24