Horde_Kolab_Cli_Data_Ledger::importFile PHP Method

importFile() public method

Import ledger data from a file.
public importFile ( string $ledger_file ) : null
$ledger_file string The file to import.
return null
    public function importFile($ledger_file)
    {
        $data = simplexml_load_file($ledger_file);
        $this->_entries = $data->entry;
    }

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;
     }
 }
All Usage Examples Of Horde_Kolab_Cli_Data_Ledger::importFile
Horde_Kolab_Cli_Data_Ledger