Bolt\Storage\Collection\Taxonomy::update PHP Метод

update() публичный Метод

Any records not in the incoming set are deleted from the collection and the deleted ones returned as an array.
public update ( Taxonomy $collection ) : array
$collection Taxonomy
Результат array
    public function update(Taxonomy $collection)
    {
        $updated = [];
        // First give priority to already existing entities
        foreach ($collection as $entity) {
            $entity->setSlug(str_replace('/', '', $entity->getSlug()));
            $master = $this->getOriginal($entity);
            $master->setSortorder($entity->getSortorder());
            $updated[] = $master;
        }
        $deleted = [];
        foreach ($this as $old) {
            if (!in_array($old, $updated)) {
                $deleted[] = $old;
            }
        }
        // Clear the collection so that we re-add only the updated elements
        $this->clear();
        foreach ($updated as $new) {
            $this->add($new);
        }
        return $deleted;
    }