public function FeatureContext::createAgents in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 behat-tests/features/bootstrap/FeatureContext.php \FeatureContext::createAgents()
@Given /^"(?P<type>[^"]*)" agents:$/
File
- behat-tests/
features/ bootstrap/ FeatureContext.php, line 167
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);
// Clear out any existing option sets/goals if this agent already existed.
$option_sets = personalize_option_set_load_by_agent($agent->machine_name);
foreach ($option_sets as $option_set) {
personalize_option_set_delete($option_set->osid);
}
$goals = personalize_goal_load_by_conditions(array(
'agent' => $agent->machine_name,
));
foreach ($goals as $goal_id => $goal) {
personalize_goal_delete($goal_id);
}
personalize_agent_set_status($saved->machine_name, PERSONALIZE_STATUS_NOT_STARTED);
}
}