Bolt\Storage\Field\Collection\RepeatingFieldCollection::addFromReferences PHP Method

addFromReferences() public method

public addFromReferences ( array $ids, integer $grouping )
$ids array
$grouping integer
    public function addFromReferences(array $ids, $grouping = 0)
    {
        $collection = new FieldCollection($ids, $this->em);
        $collection->setGrouping($grouping);
        $this->add($collection);
    }

Usage Example

Beispiel #1
0
 public function hydrate($data, $entity)
 {
     $key = $this->mapping['fieldname'];
     $vals = array_filter(explode(',', $data[$key]));
     $values = [];
     foreach ($vals as $fieldKey) {
         $split = explode('_', $fieldKey);
         $values[$split[0]][$split[1]][] = $split[2];
     }
     $collection = new RepeatingFieldCollection($this->em, $this->mapping);
     $collection->setName($key);
     if (isset($values[$key]) && count($values[$key])) {
         foreach ($values[$key] as $group => $refs) {
             $collection->addFromReferences($refs, $group);
         }
     }
     $this->set($entity, $collection);
 }
All Usage Examples Of Bolt\Storage\Field\Collection\RepeatingFieldCollection::addFromReferences