Find unsaved children inside an object.

@param AVObject $object Object to search.
@param array &$unsavedChildren Array to populate with children.
@param array &$unsavedFiles Array to populate with files.
518013
private static function findUnsavedChildren(
        $object,
        &$unsavedChildren,
        &$unsavedFiles
    ) {
        static::traverse(true, $object, function ($obj) use (
            &$unsavedChildren,
            &$unsavedFiles
        )
        {
            if ($obj instanceof AVObject)
            {
                if ($obj->_isDirty(false))
                {
                    $unsavedChildren[] = $obj;
                }
            } else if ($obj instanceof AVFile)
            {
                if (!$obj->getURL())
                {
                    $unsavedFiles[] = $obj;
                }
            }

        });
    }
1262865
public function updateLevelForChildrenElements($object)
    {

        $tmp = new \Doctrine\Common\Collections\ArrayCollection();

        $children = $this->findChildrenByParentId($object->getId());

        foreach ($children as $ch) {
            $tmp->add($ch);
        }

        while (!$tmp->isEmpty()) {
            $d = $tmp->first();
            $tmp->removeElement($d);
            $children = $d->getChildren();
            foreach ($children as $ch) {
                $tmp->add($ch);
            }
            $parent = $d->getParent();
            $d->setLevel($parent->getLevel() + 1);
            $this->updateWithoutPreAndPostUpdate($d);
        }

    }
580997
public static function getObjectClass($object)
    {
        if(is_object($object))
        {
            if($object instanceof IBean)
            {
                return get_parent_class($object);
            }
            else
            {
                return get_class($object);
            }
        }
        else
        {
            return (string)$object;
        }
    }
1344492
public function unembed(string $field, &$obj)
    {
        $embedder = Ioc::make(DocumentEmbedder::class);
        $embedder->unembed($this, $field, $obj);
    }
1283759
public function persist($objects)
    {
        if (!is_array($objects) && !$objects instanceof \Traversable) {
            $objects = array($objects);
        }
        foreach ($objects as $object) {
            if (!is_object($object)) {
                throw new UnexpectedTypeException($object, 'object');
            }
            $this->unitOfWork->persist($object);
        }
    }
604497
public function extract($object)
    {
        if (!$object instanceof DownloadList) {
            throw new Exception('$object must be an instance of Downloadlist');
        }
        /* @var $object DownloadList */
        $data = parent::extract($object);

        return $data;
    }
791148
protected function restoreObjectRelations(IObject $object, array $relatedValues)
    {
        foreach ($relatedValues as $propertyName => $value) {
            $property = $object->getProperty($propertyName);
            $property->setInitialValue(null);
            $property->setValue($value);
        }
    }
725395
protected function doesContainsObjects(array $objects) : bool
    {
        $this->toOrderedMap();

        foreach ($objects as $object) {
            if (!isset($this->instanceMap[$object])) {
                return false;
            }
        }

        return true;
    }
1077497
public static function exportObjectMethods($object) {
        $methods = [];
        foreach (get_class_methods($object) as $method) {
            if ($method[0] === '_') {
                continue;
            }
            $methods[$method] = [$object, $method];
        }
        return $methods;
    }
1266809
protected function getObjectGetterValues($methods, $object, array &$out = [])
    {
        foreach ($methods as $method) {
            $this->setObjectGetterValue($method, $object, $out);
        }
    }
813312
public function updatePositionForSiblingsElements($object, $removed = false)
    {

        if (!is_null($object->getParent())) {
            $children = $this->findChildrenByParentId($object->getParent()->getId());
            $i = 1;
            $f = false;
            foreach ($children as $ch) {
                if ($removed && $ch->getId() != $object->getId()) {
                    $ch->setPosition($i);
                    $this->updateWithoutPreAndPostUpdate($ch);
                    $i++;
                } else if (!$removed) {
                    if (!$f && $ch->getPosition() >= $object->getPosition()) {
                        $f = true;
                        $object->setPosition($i);
                        if ($ch->getId() != $object->getId()) {
                            $ch->setPosition($i + 1);
                            $i++;
                        }
                    } else if ($ch->getId() != $object->getId()) {
                        $ch->setPosition($i);
                    }
                    $this->updateWithoutPreAndPostUpdate($ch);
                    $i++;
                }
            }
        }

        return true;
    }
1212840
private function resolveChildren()
    {
        foreach ($this->unresolvedChildren as $name => $info) {
            $this->children[$name] = $this->create($name, $info[0], $info[1]);
        }

        $this->unresolvedChildren = [];
    }
1313535
public function hasObject($object)
    {
        $oid = spl_object_hash($object);
        if (!isset($this->objectsRepository[$oid])) {
            return false;
        }
        $repository = $this->objectsRepository[$oid];
        $data = $repository->getHydrator()->unhydrate($object);
        $id = isset($data['_id']) ? serialize($data['_id']) . $repository->getCollection() : $oid;

        return isset($this->objects[$oid]) || isset($this->objects[$id]);
    }
820294
final protected function checkArrayCollection($object)
    {
        return $object instanceof \Doctrine\Common\Collections\ArrayCollection || $object instanceof \Doctrine\ORM\PersistentCollection;
    }
58835
protected function persist($object)
    {
        if(!$object->getId()) {
            $object->setId($this->getNextId());
        }
        $key = $this->getHash().$object->getId();
        $content = serialize($object);
        
        $this->getFileManager()->write($key, $content, true);
    }
353823
public function retornaClassesMaes($object)
    {
        $class = new ReflectionClass($object);

        $parents = [];
        $parent  = "";
        if ( self::verificaSeEClasseFilha($object) ) {
            while ($class->getParentClass()) {
                $parents[] = $class->getParentClass()->getName();
                $class     = $parent;
            }

            return $parents;
        }

        return false;
    }
948166
public function loadFromArray ($object)
    {
        parent::loadFromArray($object);

        if (!empty($this->recipients->items)) {
            foreach($this->recipients->items AS &$item) {
                $Recipient = new Recipient();
                $Recipient->loadFromArray($item);

                $item = $Recipient;
            }
        }