Exemplo n.º 1
0
 public function serializeCollection(Collection $collection, array $options = [])
 {
     $this->normalizeOptions($options);
     $xml = $this->initXml($options);
     if ($collection->any()) {
         $collection->rewind();
         $first = $collection->current();
         $inflector = $first->getService('inflector');
         if (!isset($options['root'])) {
             $arrayName = $inflector->pluralize($this->properElementName($options, ClassTools::getClassName($first)));
         } else {
             $arrayName = $options['root'];
         }
         $options['root'] = $inflector->singularize($arrayName);
         $xml->write($arrayName, ['type' => 'array'], function ($x) use($collection, $options) {
             foreach ($collection as $member) {
                 $this->writeModel($x, $member, $options);
             }
         });
     } else {
         $xml->write($this->properElementName($options, 'nullClasses'), ['type' => 'array']);
     }
     return $xml->markup();
 }
Exemplo n.º 2
0
 public function includeFactories(array $paths)
 {
     $includer = ClassTools::generateFileIncluder($this);
     foreach ($paths as $path) {
         foreach (FileTools::listFilesRecursive($path) as $file) {
             $includer($file->getRealPath());
         }
     }
 }