makinacorpus/drupal-usync 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

makinacorpus/drupal-usync

Composer 安装命令:

composer require makinacorpus/drupal-usync

包简介

Drupal features-like configuration file driven synchronization module

README 文档

README

Minimal yet powerfull config file based features-like toolkit for Drupal 7.

How does it work

It works by building a fully featured AST composed of typed nodes representing your configuration file, then browsing the tree and executing code over it.

Getting started

Create a sample module

Let's assume you are working on a custom blog module:

sites/all/modules/myblog/
    myblog.module
    myblog.info
    myblog.yml

Contents of the myblog.info file:

name = My blog feature
description = Very simple blog feature for my site.
core = 7.x
usync[] = myblog.yml

Contents of the myblog.yml file:

field:
  blog_image:
    label: Post photo
    type: image

entity:
  blog_post:
    blog:
      name: Blog post
      field:
        blog_image: true
        body: true

view:
  node:
    blog_post:

      default:
        post_image:
          type: image
          settings:
            image_style: thumbnail
        body: true

      teaser:
        blog_image:
          type: image
          settings:
            image_style: thumbnail
        body:
          type: text_summary_or_trimmed
          settings:
            trim_length: 200

List available data sources on site

> drush usync-list

Module  Source
myblog  myblog.yml 

List available data in tree

There is three alternative syntaxes for this use case.

Show a tree of everything declared by the myblog module:

> drush usync-tree --source=myblog:

Show a tree of the myblog.yml file declared by the myblog module:

> drush usync-tree --source=myblog:myblog.yml

Show a tree of the myblog.yml file accessing it directly:

> drush usync-tree --source=sites/all/modules/myblog/myblog.yml

Note that the --source parameter will be the same for all drush commands of this module, which means you can work directly on files without those needing to be defined by a specific module.

Output for the sample file should be:

 + field.blog_image
 + field.body
 + entity.node.post.field.blog_image
 + entity.node.post.field.body
 + entity.node.post
 + view.node.blog_post.default
 + view.node.post.teaser

Listing matching elements in tree

Let's use the same source as upper, our 'myblog' module.

> drush usync-tree --source=myblog: \
    --match=entity.node.%

 + entity.node.post

Matching rules are the following:

  • Words will match node names strictly

  • % wildcard will match any name

Injecting configuration into Drupal

Now that you are experienced users of the --source and --match parameters you can proceed to Drupal injection. Just replace the usync-tree command by usync-run using the same parameters and it will work.

For example, inject everything which is in the file:

> drush usync-tree --source=myblog:

Once everything is injected, you can proceed to partial updates, for example revert all the view modes:

> drush usync-tree --source=myblog:
    --match=view.node.blog_post.%

FAQ

But why?

Why not. Features is slow to revert, features need to be configured via the UI, and features are not easy to modify manually, features may bring weird conflicts, and features don't know what to do when there is an error and get broken. You can't define things easily, you can make objects inherit from each other one, and features uses CTools, supports Views, and push forward very bad practices. Drupal Way is unperformant, unperforming, and I needed something to write things faster and make things run faster.

But why Yaml?

Why not, and you can use plain old PHP arrays instead if you don't like it. It will work like a charm.

Why should I use it?

I'm not your mamma, if you like to click, use features. Choice is yours. Oh and it's an experimental, unfinshed product, so I would be you, I wouldn't use it.

makinacorpus/drupal-usync 适用场景与选型建议

makinacorpus/drupal-usync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 956 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 makinacorpus/drupal-usync 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2
  • 更新时间: 2016-06-01