This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rule = rules_reaction_rule(); | |
$rule->event('node_insert') | |
->condition(rules_or()->condition(rules_and())) | |
->condition(rules_condition('data_is', array('data:select' => 'node:status', 'value' => TRUE))->negate()) | |
->condition('data_is', array('data:select' => 'node:type', 'op' => 'IN', 'value' => array('page', 'story'))) | |
->condition('data_is', array('data:select' => 'node:type', 'op' => 'IN', 'value' => array('page', 'story'))); | |
$rule->save('test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rule = rules_reaction_rule(); | |
$rule->event('node_insert'); | |
$rule->condition('data_is', array('data:select' => 'node:type', 'op' => 'IN', 'value' => array('product'))); | |
$rule->condition(rules_or() | |
->condition('data_is', array('data:select' => 'node:product:0:type', 'value' => 'shirt')) | |
->condition('data_is', array('data:select' => 'node:product:author:uid', 'value' => 1)) | |
); | |
$rule->action('data_set', array('data' => 'node:status', 'value' => 1)); | |
$rule->save(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$remote = new RulesWebRemote(); | |
$remote->name = 'calais'; | |
$remote->label = 'Open calais'; | |
$remote->url = 'http://api.opencalais.com/enlighten/?wsdl'; | |
$remote->type = 'soap'; | |
// Add info about the SOAP service, which the user has to provide via the UI. | |
// We need to define the "Enlighten" complex data type, which the operation | |
// takes as parameter. | |
$remote->settings['data types']['Enlighten'] = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$comments = comment_load_multiple(); | |
for ($i =0; $i<1; $i++) { | |
foreach ($comments as $comment) | |
foreach ($comment as $name => $property) | |
foreach ($property as $item) | |
foreach ($item as $value) | |
$value->getType(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$iterations = 10000; | |
timer_start('test'); | |
for ($i = 0; $i < $iterations; $i++) { | |
$d = serialize($definitions); | |
$e = unserialize($d); | |
} | |
timer_stop('test'); | |
echo timer_read('test')."ms for $iterations runs. \n"; | |
echo (timer_read('test') / $iterations) ."ms per run"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements \Drupal\Core\Executable\ExecutableInterface::valdidate(). | |
*/ | |
public function valdidate() { | |
$violations = new \Symfony\Component\Validator\ConstraintViolationList(); | |
if ($definitions = $this->getContextDefinitions()) { | |
foreach ($definitions as $key => $definition) { | |
// Validate any set values. | |
if (isset($this->context[$key])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print_r($typed_data->getPropertyDefintions()); | |
foreach ($typed_data as $name => $property) { | |
// Property is type data as well | |
echo $property->getType(); | |
// introspect property? check it's interface and continue | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function assertIterator($entity_type) { | |
$entity = $this->createTestEntity($entity_type); | |
foreach ($entity as $name => $field) { | |
$this->assertTrue($field instanceof FieldInterface, $entity_type . ": Field $name implements interface."); | |
foreach ($field as $delta => $item) { | |
$this->assertTrue($field[0] instanceof FieldItemInterface, $entity_type . ": Item $delta of field $name implements interface."); | |
foreach ($item as $value_name => $value_property) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::setContextValue(). | |
*/ | |
public function setContextValue($key, $value) { | |
$context_definition = $this->getContextDefinition($key); | |
$this->context[$key] = new Context($context_definition); | |
$this->context[$key]->setValue($value); | |
if ($this->context[$key]->validate($value)->count() > 0) { | |
throw new PluginException("The provided value for $key is not valid."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatabaseStorageController implements EntityStorageControllerInterface, ExtensibleStorageInterface { | |
protected $class = 'ExtensibleDBStorageHelper'; | |
protected function getExtensibleStorageHelper() { | |
... | |
} | |
function save() { |
OlderNewer