コード例 #1
0
 /**
  * Read the template and XML and mark services as being in use if they are
  * allowed in the template and enabled in the XML.
  */
 private function markUsedServicesFromXML(SimpleXMLElement $xml, $template_id, ServiceManager $service_manager = null, ProjectManager $project_manager = null)
 {
     $template = $project_manager->getProject($template_id);
     $services_by_name = array();
     foreach ($service_manager->getListOfAllowedServicesForProject($template) as $service) {
         $services_by_name[$service->getShortName()] = $service;
     }
     foreach ($xml->services->children() as $service) {
         if (!$service instanceof SimpleXMLElement) {
             continue;
         }
         if ($service->getName() !== "service") {
             continue;
         }
         $attrs = $service->attributes();
         $name = (string) $attrs['shortname'];
         $enabled = $attrs['enabled'] == 'true' || $attrs['enabled'] == '1';
         if (isset($services_by_name[$name])) {
             $service_id = $services_by_name[$name]->getId();
             $this->data_services[$service_id] = array('is_used' => $enabled);
         }
     }
 }