16、提供新的事件、条件和操作:扩展Drupal规则框架的深度指南

提供新的事件、条件和操作:扩展Drupal规则框架的深度指南

1. 引言

在Drupal开发中,规则框架是一个非常强大的工具,可以让你在不编写代码的情况下创建复杂的业务逻辑。然而,有时默认的事件、条件和操作并不能满足特定项目的需求。为了应对这种情况,我们可以创建自定义的事件、条件和操作,以扩展规则框架的功能。本文将详细介绍如何通过实现相应的钩子函数来创建这些自定义元素,并提供具体的代码示例和实现步骤。

2. 创建自定义事件

自定义事件允许你在特定情况下触发规则,从而使规则框架更加灵活。要创建一个新的事件,你需要实现 hook_rules_event_info() 钩子。这个钩子返回一个事件数组,其中键是事件的机器可读名称,值是关于该事件的详细信息。

2.1 实现 hook_rules_event_info()

/**
 * 实现 hook_rules_event_info()。
 * 定义我们的新自定义事件用于规则。
 */
function custom_rules_event_info() {
  return array(
    'custom_views_render' => array(
      'label' => '一个视图正在渲染',
      'group' => '规则自定义',
      'variables' => array(
        'view' => array(
          'type' => 'custom_view_dat

相关推荐

Ubuntu VPS上创建Drupal 7 Omega 4子主题完整指南

Drupal子主题是实现安全定制与版本可控的核心机制,其本质是通过继承关系隔离修改、避免破坏父主题稳定性。Omega 4作为Drupal 7主流响应式主题框架,依赖PHP扩展、Node.js构建工具链及严格Linux文件权限体系,技术价值在于提供可复用的网格系统、LESS预编译样式和可视化布局管理。典型应用场景包括企业官网重构、遗留Drupal 7站点前端升级、以及需要SSH环境交付的外包项目。本文聚焦Ubuntu VPS这一无GUI服务器环境,详解从LAMP部署、omega-subtheme脚本生成、Gr

weixin_34060741的博客 476

Drupal 7在CentOS 6虚拟服务器上的兼容部署与故障排查

Drupal 是一款成熟开源内容管理系统,其 7.x 系列是唯一官方支持 CentOS 6 的主版本;CentOS 6 虽已停止维护,但在政企、医疗、教育等内网环境中仍广泛运行于虚拟服务器之上,构成典型的 LAMP(Apache 2.2 + PHP 5.3–5.6 + MySQL 5.1)遗留栈。该环境的核心挑战在于组件兼容性、SELinux 策略约束与安全加固要求之间的张力——例如 PHP 扩展缺失、mod_rewrite 配置失效、MySQL socket 路径被重定向等问题,均非标准文档可覆盖。本文聚

weixin_33834910的博客 337

Metasploit渗透测试框架:从漏洞利用到内网漫游的完整攻击链解析

在网络安全领域,渗透测试是评估系统安全性的核心方法,其本质是通过模拟攻击来发现潜在风险。其基本原理是遵循标准化的攻击生命周期,从信息收集、漏洞扫描到利用和后渗透。这一过程的技术价值在于将复杂的攻击技术模块化、自动化,从而降低安全验证的门槛,并帮助防御者理解攻击者的思维和路径。在工程实践中,这通常涉及对常见服务漏洞的利用、权限提升和横向移动。应用场景广泛,包括企业安全评估、红队演练和教育培训。本文聚焦于Metasploit这一综合性渗透测试框架,它集成了**漏洞利用**和**后渗透**等关键阶段,通过模块化设

weixin_33734785的博客 423

Ubuntu 22.04 + LAMP 部署 WordPress 6.4 深度指南

WordPress 不是即装即用的应用,而是深度依赖 LAMP 栈(Linux、Apache、MySQL、PHP)精密协同的服务系统。其运行原理涉及 Apache 虚拟主机与 .htaccess 重写机制的闭环配合、MySQL 8.0 认证插件(caching_sha2_password)与权限模型的适配、PHP 8.1 扩展依赖与时区强制声明等底层约束。技术价值在于构建可审计、可复用、安全加固的服务基线——既规避 apt 包管理导致的路径污染与版本错位,又通过文件权限控制、OPcache 调优和 Redi

weixin_30613727的博客 333

Ubuntu 18.04 Apache Event MPM + PHP-FPM 高并发部署指南

Apache 的 MPM(多路处理模块)是决定 Web 服务器并发能力的核心机制,其中 Event MPM 采用异步事件驱动模型,显著优于传统 prefork 模式;PHP-FPM 则作为独立的 FastCGI 进程管理器,实现 PHP 执行与 HTTP 服务的彻底解耦。这种组合不仅规避了 mod_php 的内存冗余和线程安全问题,更通过 Unix socket 通信、OPcache 协同与资源池隔离,大幅提升稳定性与吞吐量。它特别适用于 WordPress、Laravel 等 PHP 应用在中低配 VPS

www.itmmd.com 366

CentOS 8 LEMP 部署实战:dnf、SELinux 与 systemd 深度适配指南

LEMP(Linux + Nginx + MySQL + PHP)是现代 Web 服务的基础架构模型,其核心在于组件间的系统级协同,而非简单安装。在 CentOS 8 中,传统部署方式失效的根源在于底层机制升级:dnf 取代 yum 成为默认包管理器,systemd 深度接管服务生命周期,而 SELinux 默认启用 enforcing 模式并强化策略限制。这些变化直接影响 Nginx 与 PHP-FPM 的 socket 通信、PHP 访问网站文件的权限判定,以及 MySQL 连接的安全认证流程。掌握 d

dht91597的博客 377

John the Ripper与Hashcat实战指南:从密码破解到安全防御

在信息安全领域,密码哈希是验证身份和保护数据的核心机制。其原理是将用户密码通过单向散列函数转换为固定长度的字符串,确保即使数据泄露,原始密码也难以被直接获取。理解哈希算法和破解技术对于评估系统健壮性至关重要,这直接关系到数据安全的有效性。John the Ripper和Hashcat作为行业标杆工具,分别以灵活的规则引擎和极致的GPU加速性能,为安全工程师提供了从原理到实践的绝佳入口。通过它们,可以直观验证密码策略的强度,并应用于渗透测试、安全审计和密码恢复等合规场景。掌握这些工具,不仅能提升对常见攻击如字

weixin_30954265的博客 532

CTF密码破解实战:Hashcat核心攻击模式与性能调优指南

哈希(Hash)是一种将任意长度数据映射为固定长度摘要的单向加密函数,广泛应用于密码存储与数据完整性校验。其核心原理是通过特定算法(如MD5、SHA系列)生成唯一指纹,理论上不可逆。在信息安全领域,高效破解哈希对于渗透测试、数字取证及CTF竞赛至关重要。Hashcat作为一款支持GPU加速的密码恢复工具,通过多种攻击模式(如字典、掩码、混合攻击)极大提升了破解效率。在CTF竞赛中,选手常面临**加盐哈希**与**掩码攻击**等场景,需结合题目提示精准构造字典与掩码,并利用Hashcat的会话管理、性能调优功

weixin_33923762的博客 444

CESM2 实验笔记

文章目录1. 重新启动1.1 关于重启文件2. RUN_TYPE 初始化运行方式startupbranchhybrid3. branch 或者 hybrid运行的示例4. 其他声明5. 关于RESUBMIT 1. 重新启动 参考: https://bb.cgd.ucar.edu/cesm/threads/how-to-restart-cesm2-1-3-fhist-from-a-backup.5245/#post-36275 适用情况:模型运行因时间不足或其它原因中断,需要继续运行 方法1:将CONTIN

qq_38607066的博客 1万+

软件工程:数据字典

数据字典

永远怀着至诚之心拥抱世界 4275

MaixCAM2 4K AI相机硬件解析与开发实战

嵌入式AI视觉开发中,边缘计算设备的选择直接影响项目落地效果。以NPU为核心的AI加速技术通过专用指令集优化,可在低功耗下实现10+TOPS算力,典型应用包括工业质检、智能门禁等实时场景。MaixCAM2作为新一代4K AI相机,搭载AX630 SoC芯片,其双核Cortex-A53与NPU的异构架构,在运行YOLOv11n模型时可达113FPS,显著优于传统方案。开发时需注意模型量化部署技巧,如INT8量化需500+张校准图片覆盖多光照条件,避免准确率下降。设备扩展性方面,PMOD接口支持热成像、ToF传

weixin_30819085的博客 690

D2D与C2C高速互联技术对比:从封装到性能的全面解析

本文全面解析了Die-to-Die(D2D)与Chip-to-Chip(C2C)高速互联技术的差异,从封装形式、传输距离到性能指标进行深度对比。D2D技术在带宽、延迟和能效方面具有显著优势,适用于高性能计算和AI加速;而C2C技术则更适合车载电子系统等长距离传输场景。文章还探讨了UCIe标准化趋势,并提供了技术选型的实用建议。

weixin_29197051的博客 553

1. SAP Fiori Elements 开发环境的搭建和开发准备工作

本文介绍了本地使用 Visual Studio Code 进行 Fiori Elements 开发所需要安装的这个扩展包里6个能够提高 Fiori Elements 应用开发效率的扩展。在本教程后续步骤里我们会通过实际的例子介绍这些 Visual Studio Code 扩展的详细用法。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 3451

气象大模型光伏功率预测中的应用:从短期,超短期,中长期的实现与开源代码详解

本文详细介绍了基于大模型的光伏功率预测方法,涵盖超短期(15分钟-1小时)、短期(1-6小时)和中长期(1天-1周)预测。文章首先讨论了数据准备与预处理,包括历史功率、气象、天文和电站特性数据的收集与特征工程。随后,针对不同预测需求,提出了多种深度学习模型:超短期预测采用1DCNN-LSTM混合模型,短期预测使用Transformer模型,中长期预测则通过多尺度特征提取模型和概率预测方法处理不确定性。文章还提供了模型训练、评估、部署和优化的完整流程,并开源了代码实现。未来研究方向包括结合数值天气预报、开发时

专注AI大模型,软件混淆,授权 1573

实验三、数字PID控制器的设计

由图可知,由于微分环节的作用,在曲线的起始上升段出现了一个尖锐的波峰,之后曲线也呈衰减的振荡:随着Td增加,系统的超调量增大,但曲线尖锐的起始上升阶段后响应速度减慢,可以看出Td越小。对大多数算法,缩短采样周期可使控制回路性能改善,但采样周期缩短时,频繁的采样必然会占用较多的计算工作时间,同时也会增加计算机的计算负担,而对有些变化缓慢的受控对象无需很高的采样频率即可满意地进行跟踪,过多的采样反而没有多少实际意义。随着Kp的增加,闭环系统的超调量增加,响应速度加快,控制时间加长,稳态误差减少;

m0_51738372的博客 8023

提示词编写:从新手到专家的进阶之路

本文旨在为提示词编写者提供一条从新手到专家的进阶之路。我们将详细探讨提示词编写的背景与意义、基础与进阶技巧、实战应用以及最佳实践。通过逐步深入的分析与实操,读者将掌握提示词编写的核心要点,提高编写效率和作品质量。提示词是用于引导人工智能生成文本的关键词或短语,它包含了作者想要传达的主题、情感和细节。随着人工智能技术的普及,自动化写作工具逐渐应用于各行各业。为了提高写作效率,项目团队决定开发一款基于人工智能的自动化写作工具。成功开发了一款自动化写作工具,生成文本质量较高。

AI天才研究院 1086

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 6、癌症分子流行病学:生物标志物、影响因素与新技术
下一篇: 3、数据与应用安全:发展、挑战与解决方案
网恋被骗八块八
博客等级 码龄3年 131粉丝 1594原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值