DrupalCon Portland 2013

Cómo usar el módulo Rules sin la interfaz de usuario

David Kitchen  · 


Extracto de la transcripción automática del vídeo realizada por YouTube.

good morning everyone welcome to drupal calm I'm Nick the Dow i'll i'll be your room monitor today and if you guys need any help please let me know we're going to start out a session called rules we follow the user interface by david kitchen

from London so I'll passing the word Thank You name hi good morning everyone hope you've all got here fine and ready to start this morning so rules without the UI and how to include default rules in your module our agenda for the session we're

going to show you here it always seems to do this slow for the first slide and so we're going to do is I just going to give some introductions to myself and will them talk about talk about the actual rules module and how you can use it in your module we're

gonna have a short little break in the middle of the presentation to relax everyone and then look at a case study of how to use rules in the in your module so information about where you can find out more about using rules in your module and then time for

some questions at the end so I'm dead kitchen I said I work for commerce guys I started there in October this year sorry Toby last year with a date wrong they'll but we have opened the office in the UK let and that's when I started and here are

some of the modules that I worked on I look after a module for doing European v80 but also worked on payment gateways recommender system and other modules including car loan file which is just recently being released and a lot of these modules all use rules

and it is quite a core part of commerce and how it works so I hope that's sir something's going to talk about and pick out here so the rules module itself it's a system for providing event condition acts and programming and it's maintained

by a bull cans i go or fargo on drupal dork and so that's the URL for it there i'm sure you've all used it and just to you know that i just wanted to get some idea of what we've got in the audience here so get a show of hands who who's

written a rule using the UI and as anyone written some their own events or actions in rules to using them and as anyone we actually written a default rule using code and including their module yet that's so that's that's good that's that's

what you're here to find out about so and just going through why we want to support rules so rules actually is really easy to use it's non intrusive and and it unifies functionality between modules and provides good practice to learn from as well so

it's a framework for event condition action programming it can be used by lots of other modules once you've started using rules so that includes things like views bulk operations once you've provided some rules which I to you can use real views

book operations can use rules to provide those operations and you can combine with other modules to provide some really useful functionality that a site builder can use for their benefits when I actually using a site so i just got this here this is a quote

from a blog post from window crowds which is I think really useful that rules is a complex framework to some extent it is heavy but a fact that event condition action style modules are pretty common and it doesn't make sense not to have a free work for

them rules may not be the perfect tool but it but it is a good tool that can be improved so setting that blog post from 2011 and some of the key points about rules it is configurable exportable you can clone them reuse the components and it provides a unified

functionality across systems and you can really get some some quick solutions and even yesterday here's an example this was on Sunday there was a module released which is an API for Jenkins and it is just basically a set of rules actions that can be used

by anyone now to integrate with their own site build or module and once those actions have been provided they're really easy to venues within rules so it provides in actions for triggering a build and creating a new job or copying an existing job within

the system and that's so this is that the whole point of using rules someone if those were just actions within a module that someone has to go away and start coding interacting with it's a lot more work for actually building a site so start to look

at how you can support rules in your module that you're developing the first part is a rules link module and this provides a data info about what your module can provide to rules and this covers data types so if your module provides a specific data type

beyond the standards that are available to the strings and integers you can provide details of that here and one of the examples of those is the dat module provides a data type the taxes in that are in commerce it exposes those as a data type in rules to use

it for conditions you can then provide events and so this is when something is happening within your module you can provide an event that can be used to trigger a reaction rule conditions so this is where you're trying to provide a simple one-step condition

rules provide some standard conditions for comparing strings or integers or boolean values but if you have got a complex condition you can provide some functionality that actually reviews those and then the actions this is generally providing a the information

about functions in your module and how rules can use those to create an event action from those if you're providing entities within your module it's really quick and easy to get some information about those entities into rules so by just making sure

your entity info and entity property info has full of set of information about create save and delete access callbacks the properties that are available on the entity type once you've provided all that information in those hooks the rules will pick all

of those up and be able to provide those as actions for creating and saving and editing those entities in the rules actions here and of course those if you're dealing with a entity that's provided by another module then you can use the entity info

alter to add those in if they're missing from another entity type so the cool part of this the default rules is a just like you might have done in views providing a default view there's a file just to be slightly confusing it's got an s on defaults

but once you've got that module there with that file there with your hook default rules configurations in that's returning an array of the rule object you can provide those default rules in there and there is also a default rules configuration ulta

hook to provide and alter rules that are praveen provided by another module so the rules components there are the first part first type of rule is the reaction rule this is the core parts it has three parts to the rule the event the conditions and actions

there's always at least one events for a reaction rule but you can have multiples so this could be on saving a entity or creating an entity as both of them are two different events within the rules at events system conditions again multiple conditions

providing the requirements that need to be passed for this rule to take place and then the actions again multiple actions taking any of the information that's gathered in the events so if the event was saving a user then you've got the user entity

[ ... ]

Nota: se han omitido las otras 3.628 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.