protected function parseActivity(AgaviXmlConfigDomElement $activity_node, AgaviXmlConfigDomDocument $document) { // description for this activity $description_node = $activity_node->getChild('description'); $description = $description_node ? $description_node->getValue() : ''; // short label for this activity $label_node = $activity_node->getChild('label'); $label = $label_node ? $label_node->getValue() : ''; // verb (request method equivalent) for this activity $verb_node = $activity_node->getChild('verb'); $verb = $verb_node ? $verb_node->getValue() : AgaviConfig::get('activities.default_verb', self::DEFAULT_VERB); // link relations for the target url of this activity $rels = []; $rels_node = $activity_node->getChild('rels'); if (!empty($rels_node) && $rels_node->hasChildren('rel')) { foreach ($rels_node->get('rel') as $rel_node) { $rels[] = $rel_node->getValue(); } } // mime types the target url supports as input $accepting = []; $acception_node = $activity_node->getChild('accepting'); if (!empty($accepting_node)) { foreach ($accepting_node->get('type') as $type_node) { $accepting[] = $type_node->getValue(); } } // mime types the target url supports as output $sending = []; $sending_node = $activity_node->getChild('sending'); if (!empty($sending_node)) { foreach ($sending_node->get('type') as $type_node) { $sending[] = $type_node->getValue(); } } // parse all settings from given settings node $settings_node = $activity_node->getChild('settings'); $settings = $settings_node ? $this->parseSettings($settings_node) : []; if (!array_key_exists('form_id', $settings)) { $settings['form_id'] = 'randomId' . rand(); } // URL, URI_TEMPLATE or ROUTE_NAME for target url of this activity $url = ['type' => self::DEFAULT_URL_TYPE, 'value' => '']; $url_node = $activity_node->getChild('url'); if (!empty($url_node)) { $url_value = trim($url_node->getValue()); $url_type = $url_node->getAttribute('type'); if (!empty($url_type)) { if (!in_array($url_type, $this->allowed_url_types)) { throw new ConfigError(sprintf('Configuration file "%s" must specify a valid "type" attribute' . 'on "url" elements. Valid are: ', $document->documentURI, implode(', ', $this->allowed_url_types))); } $url['type'] = $url_type; } if (empty($url_value)) { throw new ConfigError(sprintf('Configuration file "%s" must specify a valid value for "url" elements.', $document->documentURI)); } if ($url_value === 'null') { $url_value = null; // useful for $ro->gen(null, …) } else { $url_value = AgaviToolkit::literalize(AgaviToolkit::expandDirectives($url_value)); } $url['value'] = $url_value; } $url['parameters'] = $this->parseUrlParameters($activity_node); $url = new Url($url); return ['name' => trim($activity_node->getAttribute('name')), 'type' => $activity_node->getAttribute('type', 'general'), 'description' => $description, 'label' => $label, 'verb' => $verb, 'rels' => $rels, 'accepting' => $accepting, 'sending' => $sending, 'settings' => $settings, 'url' => $url->toArray()]; }