Beispiel #1
0
 /**
  * A DataObject is related to a container and has a name
  *
  * If `$name` is specified, then it attempts to retrieve the object from the
  * object store.
  *
  * @param Container $container the container holding this object
  * @param mixed $cdata if an object or array, it is treated as values
  *      with which to populate the object. If it is a string, it is
  *      treated as a name and the object's info is retrieved from
  *      the service.
  * @return void
  */
 public function __construct($container, $cdata = NULL)
 {
     parent::__construct();
     $this->container = $container;
     if (is_object($cdata)) {
         foreach ($cdata as $property => $value) {
             if ($property == 'metadata') {
                 $this->metadata->SetArray($value);
             } else {
                 $this->{$property} = $value;
             }
         }
     } elseif (isset($cdata)) {
         $this->name = $cdata;
         $this->Fetch();
     }
 }
Beispiel #2
0
 /**
  * Creates the container object
  *
  * Creates a new container object or, if the $cdata object is a string,
  * retrieves the named container from the object store. If $cdata is an
  * array or an object, then its values are used to set this object.
  *
  * @param OpenCloud\ObjectStore $service - the ObjectStore service
  * @param mixed $cdata - if supplied, the name of the object
  */
 public function __construct(AbstractService $service, $cdata = NULL)
 {
     $this->debug(Lang::translate('Initializing Container...'));
     parent::__construct();
     $this->service = $service;
     // set values from an object (via containerlist)
     if (is_object($cdata)) {
         foreach ($cdata as $name => $value) {
             if ($name == 'metadata') {
                 $this->metadata->SetArray($value);
             } else {
                 $this->{$name} = $value;
             }
         }
         //$this->Refresh();
     } elseif ($cdata) {
         // or, if it's a string, retrieve the object with that name
         $this->debug(Lang::translate('Getting container [%s]'), $cdata);
         $this->name = $cdata;
         $this->Refresh();
     }
 }