Exemple #1
0
 /**
  * This constructor initializes the class with the data model(s).
  *
  * @access public
  * @param string $type                                      the type of translator
  * @param Common\IMap $models                               the data models to be translated
  */
 public function __construct($type, Common\IMap $models)
 {
     parent::__construct($models);
     $components = preg_split('/(\\\\|_)+/', '..\\..\\..\\..\\' . trim($type, '\\'));
     $uri = dirname(__FILE__) . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $components) . '.xml';
     $this->resource = Core\Data\XML::load(new IO\File($uri));
     $this->name = $components[count($components) - 1];
     $assigns = $this->resource->xpath("/translators/translator[@name='{$this->name}']/defaults/assign");
     foreach ($assigns as $assign) {
         $this->parseAssignElement($assign);
     }
     $methods = $this->resource->xpath("/translators/translator[@name='{$this->name}']/fields/field");
     $this->methods = array();
     foreach ($methods as $method) {
         $attributes = $method->attributes();
         $name = $this->__valueOf($attributes['name']);
         $scope = $this->__valueOf($attributes['scope']);
         switch ($scope) {
             case 'get':
             case 'uget':
             case 'set':
             case 'uset':
                 $this->methods[] = $scope . $name;
                 break;
         }
     }
 }
Exemple #2
0
 /**
  * This method returns the processed resource as a collection.
  *
  * @access public
  * @param string $path                                      the path to the value to be returned
  * @return mixed                                            the resource as a collection
  */
 public function read($path = null)
 {
     $xml = Core\Data\XML::load($this->file);
     $directives = $xml->getProcessingInstruction('php-marshal');
     if (isset($directives['expandableProperties'])) {
         $this->directives->putEntry('expandableProperties', new Common\HashSet(preg_split('/\\s+/', $directives['expandableProperties'])));
     }
     $collection = $this->parseRootElement($xml);
     if ($path !== null) {
         $collection = Config\Helper::factory($collection)->getValue($path);
     }
     return $collection;
 }