/**
  * @param string $url
  * @param File $file
  */
 public function __construct($url, File $file = null)
 {
     $this->url = $url;
     $this->file = $file;
     $this->failover = $file;
     parent::__construct();
 }
 public function __construct($fragment = null)
 {
     if ($fragment) {
         $this->setContent($fragment);
     }
     parent::__construct();
 }
 /**
  * Create a new RSSFeed entry.
  * @param ViewableData $entry
  * @param string $titleField
  * @param string $descriptionField
  * @param string $authorField
  */
 public function __construct($entry, $titleField, $descriptionField, $authorField)
 {
     $this->failover = $entry;
     $this->titleField = $titleField;
     $this->descriptionField = $descriptionField;
     $this->authorField = $authorField;
     parent::__construct();
 }
 /**
  * @param Object $obj
  * @param string $link
  * @param bool $isCurrent
  * @param string $numChildrenMethod
  * @param LeftAndMain_SearchFilter $filter
  */
 public function __construct($obj, $link = null, $isCurrent = false, $numChildrenMethod = 'numChildren', $filter = null)
 {
     parent::__construct();
     $this->obj = $obj;
     $this->link = $link;
     $this->isCurrent = $isCurrent;
     $this->numChildrenMethod = $numChildrenMethod;
     $this->filter = $filter;
 }
 /**
  * Create a new version from a database row
  *
  * @param array $record
  */
 public function __construct($record)
 {
     $this->record = $record;
     $record['ID'] = $record['RecordID'];
     $className = $record['ClassName'];
     $this->object = ClassInfo::exists($className) ? new $className($record) : new DataObject($record);
     $this->failover = $this->object;
     parent::__construct();
 }
 /**
  * @param object|array $value An associative array, or an object with simple properties.
  * Converts object properties to keys of an associative array.
  */
 public function __construct($value)
 {
     if (is_object($value)) {
         $this->array = get_object_vars($value);
     } elseif (ArrayLib::is_associative($value)) {
         $this->array = $value;
     } elseif (is_array($value) && count($value) === 0) {
         $this->array = array();
     } else {
         $message = 'Parameter to ArrayData constructor needs to be an object or associative array';
         throw new InvalidArgumentException($message);
     }
     parent::__construct();
 }
 /**
  * @param ViewableData $object
  */
 public function __construct(ViewableData $object)
 {
     $this->object = $object;
     parent::__construct();
 }
Ejemplo n.º 8
0
 public function __construct($name = null)
 {
     $this->name = $name;
     parent::__construct();
 }
 public function __construct($objectClass)
 {
     $this->objectClass = $objectClass;
     parent::__construct();
 }
 /**
  *
  * @param array $items - an initial array to fill this object with
  */
 public function __construct(array $items = array())
 {
     $this->items = array_values($items);
     parent::__construct();
 }
 /**
  * Construct a DataDifferencer to show the changes between $fromRecord and $toRecord.
  * If $fromRecord is null, this will represent a "creation".
  *
  * @param DataObject $fromRecord
  * @param DataObject $toRecord
  */
 public function __construct(DataObject $fromRecord = null, DataObject $toRecord = null)
 {
     $this->fromRecord = $fromRecord;
     $this->toRecord = $toRecord;
     parent::__construct();
 }
Ejemplo n.º 12
0
 /**
  * Create a new DataList.
  * No querying is done on construction, but the initial query schema is set up.
  *
  * @param string $dataClass - The DataObject class to query.
  */
 public function __construct($dataClass)
 {
     $this->dataClass = $dataClass;
     $this->dataQuery = new DataQuery($this->dataClass);
     parent::__construct();
 }
 public function __construct($form)
 {
     $this->form = $form;
     parent::__construct();
 }
Ejemplo n.º 14
0
 /**
  * Constructor
  *
  * @param SS_List $entries RSS feed entries
  * @param string $link Link to the feed
  * @param string $title Title of the feed
  * @param string $description Description of the field
  * @param string $titleField Name of the field that should be used for the
  *                           titles for the feed entries
  * @param string $descriptionField Name of the field that should be used
  *                                 for the description for the feed
  *                                 entries
  * @param string $authorField Name of the field that should be used for
  *                            the author for the feed entries
  * @param int $lastModified Unix timestamp of the latest modification
  *                          (latest posting)
  * @param string $etag The ETag is an unique identifier that is changed
  *                         every time the representation does
  */
 public function __construct(SS_List $entries, $link, $title, $description = null, $titleField = "Title", $descriptionField = "Content", $authorField = null, $lastModified = null, $etag = null)
 {
     $this->entries = $entries;
     $this->link = $link;
     $this->description = $description;
     $this->title = $title;
     $this->titleField = $titleField;
     $this->descriptionField = $descriptionField;
     $this->authorField = $authorField;
     $this->lastModified = $lastModified;
     $this->etag = $etag;
     parent::__construct();
 }
Ejemplo n.º 15
0
 /**
  * Create a new email.
  *
  * @param string|null $from
  * @param string|null $to
  * @param string|null $subject
  * @param string|null $body
  * @param string|null $bounceHandlerURL
  * @param string|null $cc
  * @param string|null $bcc
  */
 public function __construct($from = null, $to = null, $subject = null, $body = null, $bounceHandlerURL = null, $cc = null, $bcc = null)
 {
     if ($from !== null) {
         $this->from = $from;
     }
     if ($to !== null) {
         $this->to = $to;
     }
     if ($subject !== null) {
         $this->subject = $subject;
     }
     if ($body !== null) {
         $this->body = $body;
     }
     if ($cc !== null) {
         $this->cc = $cc;
     }
     if ($bcc !== null) {
         $this->bcc = $bcc;
     }
     if ($bounceHandlerURL !== null) {
         Deprecation::notice('4.0', 'Use "emailbouncehandler" module');
     }
     parent::__construct();
 }
 public function __construct(SS_List $list)
 {
     $this->list = $list;
     $this->failover = $this->list;
     parent::__construct();
 }
 /**
  * Construct a new DataObject.
  *
  * @param array|null $record This will be null for a new database record.  Alternatively, you can pass an array of
  * field values.  Normally this constructor is only used by the internal systems that get objects from the database.
  * @param boolean $isSingleton This this to true if this is a singleton() object, a stub for calling methods.
  *                             Singletons don't have their defaults set.
  * @param DataModel $model
  * @param array $queryParams List of DataQuery params necessary to lazy load, or load related objects.
  */
 public function __construct($record = null, $isSingleton = false, $model = null, $queryParams = array())
 {
     parent::__construct();
     // Set query params on the DataObject to tell the lazy loading mechanism the context the object creation context
     $this->setSourceQueryParams($queryParams);
     // Set the fields data.
     if (!$record) {
         $record = array('ID' => 0, 'ClassName' => static::class, 'RecordClassName' => static::class);
     }
     if (!is_array($record) && !is_a($record, "stdClass")) {
         if (is_object($record)) {
             $passed = "an object of type '" . get_class($record) . "'";
         } else {
             $passed = "The value '{$record}'";
         }
         user_error("DataObject::__construct passed {$passed}.  It's supposed to be passed an array," . " taken straight from the database.  Perhaps you should use DataList::create()->First(); instead?", E_USER_WARNING);
         $record = null;
     }
     if (is_a($record, "stdClass")) {
         $record = (array) $record;
     }
     // Set $this->record to $record, but ignore NULLs
     $this->record = array();
     foreach ($record as $k => $v) {
         // Ensure that ID is stored as a number and not a string
         // To do: this kind of clean-up should be done on all numeric fields, in some relatively
         // performant manner
         if ($v !== null) {
             if ($k == 'ID' && is_numeric($v)) {
                 $this->record[$k] = (int) $v;
             } else {
                 $this->record[$k] = $v;
             }
         }
     }
     // Identify fields that should be lazy loaded, but only on existing records
     if (!empty($record['ID'])) {
         // Get all field specs scoped to class for later lazy loading
         $fields = static::getSchema()->fieldSpecs(static::class, DataObjectSchema::INCLUDE_CLASS | DataObjectSchema::DB_ONLY);
         foreach ($fields as $field => $fieldSpec) {
             $fieldClass = strtok($fieldSpec, ".");
             if (!array_key_exists($field, $record)) {
                 $this->record[$field . '_Lazy'] = $fieldClass;
             }
         }
     }
     $this->original = $this->record;
     // Keep track of the modification date of all the data sourced to make this page
     // From this we create a Last-Modified HTTP header
     if (isset($record['LastEdited'])) {
         HTTP::register_modification_date($record['LastEdited']);
     }
     // this must be called before populateDefaults(), as field getters on a DataObject
     // may call getComponent() and others, which rely on $this->model being set.
     $this->model = $model ? $model : DataModel::inst();
     // Must be called after parent constructor
     if (!$isSingleton && (!isset($this->record['ID']) || !$this->record['ID'])) {
         $this->populateDefaults();
     }
     // prevent populateDefaults() and setField() from marking overwritten defaults as changed
     $this->changed = array();
 }
 public function __construct()
 {
     $this->brokenOnConstruct = false;
     $this->setRequest(new NullHTTPRequest());
     // This will prevent bugs if setDataModel() isn't called.
     $this->model = DataModel::inst();
     parent::__construct();
 }