/**
  * Returns a one-to-many relation as a HasManyList
  *
  * @param string $componentName Name of the component
  * @param string $filter A filter to be inserted into the WHERE clause
  * @param string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, the static
  *                           field $default_sort on the component class will be used.
  * @param string $join Deprecated, use leftJoin($table, $joinClause) instead
  * @param string|array $limit A limit expression to be inserted into the LIMIT clause
  *
  * @return HasManyList The components of the one-to-many relationship.
  */
 public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = null)
 {
     $result = null;
     if (!($componentClass = $this->has_many($componentName))) {
         user_error("DataObject::getComponents(): Unknown 1-to-many component '{$componentName}'" . " on class '{$this->class}'", E_USER_ERROR);
     }
     if ($join) {
         throw new \InvalidArgumentException('The $join argument has been removed. Use leftJoin($table, $joinClause) instead.');
     }
     // If we haven't been written yet, we can't save these relations, so use a list that handles this case
     if (!$this->ID) {
         if (!isset($this->unsavedRelations[$componentName])) {
             $this->unsavedRelations[$componentName] = new UnsavedRelationList($this->class, $componentName, $componentClass);
         }
         return $this->unsavedRelations[$componentName];
     }
     // Determine type and nature of foreign relation
     $joinField = $this->getRemoteJoinField($componentName, 'has_many', $polymorphic);
     if ($polymorphic) {
         $result = PolymorphicHasManyList::create($componentClass, $joinField, $this->class);
     } else {
         $result = HasManyList::create($componentClass, $joinField);
     }
     if ($this->model) {
         $result->setDataModel($this->model);
     }
     return $result->forForeignID($this->ID)->where($filter)->limit($limit)->sort($sort);
 }
 /**
  * Returns a one-to-many relation as a HasManyList
  *
  * @param string $componentName Name of the component
  * @return HasManyList The components of the one-to-many relationship.
  */
 public function getComponents($componentName)
 {
     $result = null;
     $componentClass = $this->hasManyComponent($componentName);
     if (!$componentClass) {
         throw new InvalidArgumentException(sprintf("DataObject::getComponents(): Unknown 1-to-many component '%s' on class '%s'", $componentName, $this->class));
     }
     // If we haven't been written yet, we can't save these relations, so use a list that handles this case
     if (!$this->ID) {
         if (!isset($this->unsavedRelations[$componentName])) {
             $this->unsavedRelations[$componentName] = new UnsavedRelationList($this->class, $componentName, $componentClass);
         }
         return $this->unsavedRelations[$componentName];
     }
     // Determine type and nature of foreign relation
     $joinField = $this->getRemoteJoinField($componentName, 'has_many', $polymorphic);
     /** @var HasManyList $result */
     if ($polymorphic) {
         $result = PolymorphicHasManyList::create($componentClass, $joinField, $this->class);
     } else {
         $result = HasManyList::create($componentClass, $joinField);
     }
     if ($this->model) {
         $result->setDataModel($this->model);
     }
     return $result->setDataQueryParam($this->getInheritableQueryParams())->forForeignID($this->ID);
 }