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] = UnsavedRelationList::create($this->class, $componentName, $componentClass);
         }
         return $this->unsavedRelations[$componentName];
     }
     $joinField = $this->getRemoteJoinField($componentName, 'has_many');
     $result = HasManyList::create($componentClass, $joinField);
     if ($this->model) {
         $result->setDataModel($this->model);
     }
     $result = $result->forForeignID($this->ID);
     $result = $result->where($filter)->limit($limit)->sort($sort);
     return $result;
 }
 public function remove($item)
 {
     parent::remove($item);
     $ids = Session::get($this->itemsSessionKey());
     if (is_null($ids)) {
         return;
     }
     unset($ids[$item->ID]);
     Session::set($this->itemsSessionKey(), $ids);
 }
 public function removeAll()
 {
     parent::removeAll();
     Session::clear($this->itemsSessionKey());
     unset($_SESSION[$this->itemsSessionKey()]);
 }
 /**
  * Removes items from this list which are equal.
  * @param {string} $field unused
  */
 public function removeDuplicates($field = 'ID')
 {
     //Remove Duplicates from the state
     if (isset($this->gridField->State->StatefulListData)) {
         $this->gridField->State->StatefulListData = array_unique($this->gridField->State->StatefulListData->toArray(), SORT_REGULAR);
     }
     //Remove duplicates from the source list
     parent::removeDuplicates($field);
 }