public function FeatureContext::createAgents in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 behat-tests/features/bootstrap/FeatureContext.php \FeatureContext::createAgents()
@Given /^"(?P<type>[^"]*)" agents:$/
File
- behat-tests/
features/ bootstrap/ FeatureContext.php, line 177
Class
- FeatureContext
- Defines application features from the specific context.
Code
public function createAgents($type, TableNode $agentsTable) {
foreach ($agentsTable
->getHash() as $agentHash) {
$agent = (object) $agentHash;
$agent->plugin = $type;
$data = array();
if (!empty($agentHash['url_contexts'])) {
$data['visitor_context'] = array(
'querystring_context' => array(),
);
$contexts = explode(',', $agentHash['url_contexts']);
foreach ($contexts as $context) {
$data['visitor_context']['querystring_context'][$context] = $context;
}
}
$agent->data = $data;
$saved = personalize_agent_save($agent);
personalize_agent_set_status($saved->machine_name, PERSONALIZE_STATUS_RUNNING);
}
}