protected function _buildExtensionFromFixture($fixture, $config = false)
 {
     $path_fixture = $this->_getFixturePath($fixture);
     $this->_copyFixtureToBuild($path_fixture);
     if (!$config) {
         $config = $this->_getBaseExtensionConfig($fixture);
     }
     Pulsestorm_MagentoTarToConnect::buildExtensionFromConfig($config);
     $path_extension = $this->_getBaseBuildPath() . '/' . $config['extension_name'] . '-' . $config['extension_version'] . '.tgz';
     $path_connectxml = $this->_getBaseBuildPath() . '/var/connect/' . $config['extension_name'] . '.xml';
     $untared = $this->_untarIntoTemp($path_extension);
     $results = array();
     $results['extension'] = $path_extension;
     $results['extracted'] = $untared;
     $results['connect_xml'] = $path_connectxml;
     return $results;
 }
 /**
  * Build 'contents' node including all its child nodes.
  * @param  SimpleXMLElement $xml
  * @param  array $files
  * @return void
  */
 public static function buildContentsNode(SimpleXMLElement $xml, array $files)
 {
     $node = self::addChildNode($xml, 'contents', '');
     $call_backs = array('target' => 'Pulsestorm_MagentoTarToConnect::extractTarget', 'path' => 'Pulsestorm_MagentoTarToConnect::extractRelativePath', 'type' => 'file', 'include' => '', 'ignore' => '');
     $parent_nodes = array_reduce(array_keys($call_backs), function ($item, $key) use($node) {
         $item[$key] = Pulsestorm_MagentoTarToConnect::addChildNode($node, $key, '');
         return $item;
     });
     // Adding empty node, this is a workaround for the Magento connect bug.
     // When no empty nodes are added the first file is removed from the package extension.
     foreach ($parent_nodes as $child_key => $child_node) {
         self::addChildNode($child_node, $child_key, '');
     }
     foreach ($files as $file) {
         foreach ($parent_nodes as $key => $child_node) {
             $call_back = $call_backs[$key];
             $value = $call_back === 'file' ? $call_back : (is_callable($call_back) ? call_user_func_array($call_back, array($file)) : $call_back);
             self::addChildNode($child_node, $key, $value);
         }
     }
 }