Horde_Kolab_Cli_Data_Ledger::asXml PHP Method

asXml() public method

Return the entries as XML strings.
public asXml ( ) : array
return array An array of XML strings.
    public function asXml()
    {
        $result = array();
        foreach ($this->_entries as $entry) {
            $entry->addAttribute('xmlns:en', 'http://newartisans.com/xml/ledger-en', 'http://www.w3.org/2000/xmlns/');
            $entry->addAttribute('xmlns:tr', 'http://newartisans.com/xml/ledger-tr', 'http://www.w3.org/2000/xmlns/');
            $result[] = strtr($entry->asXML(), array('xmlns:xmlns="http://www.w3.org/2000/xmlns/" ' => ''));
        }
        return $result;
    }

Usage Example

Esempio n. 1
0
 /**
  * Run the module.
  *
  * @param Horde_Cli $cli       The CLI handler.
  * @param mixed     $options   An array of options.
  * @param mixed     $arguments An array of arguments.
  * @param array     &$world    A list of initialized dependencies.
  *
  * @return NULL
  */
 public function run($cli, $options, $arguments, &$world)
 {
     if (!isset($arguments[1])) {
         $action = 'display';
     } else {
         $action = $arguments[1];
     }
     switch ($action) {
         case 'display':
             $folders = $world['storage']->getList()->getQuery()->listByType('h-ledger');
             foreach ($folders as $folder) {
                 $cli->writeln($folder);
             }
             break;
             break;
         case 'import':
             $ledger = new Horde_Kolab_Cli_Data_Ledger();
             $ledger->importFile($arguments[3]);
             $data = $world['storage']->getData($arguments[2], 'h-ledger');
             $object = array('type' => 'h-ledger');
             foreach ($ledger->asXml() as $entry) {
                 $object['xml'] = $entry;
                 $data->create($object);
             }
             break;
         default:
             $cli->message(sprintf(Horde_Kolab_Cli_Translation::t('Action %s not supported!'), $action), 'cli.error');
             break;
     }
 }
Horde_Kolab_Cli_Data_Ledger