Preciel
Preciel

Reputation: 2837

Revert __toString

While uploading a file, I'm trying to check if a directory exists. If it doesn't exists, then I make the directory. Directory name basis is the entity name plus is id (entity-id)

if(!is_dir($this->myDir.'entity-'.$object->getParent())) {
    mkdir($this->myDir.'entity-'.$object->getParent());
}

The problem is that data from the form send the parent parameter as a __toString of it's id
How can I revert this to the parent id?

Upvotes: 2

Views: 69

Answers (1)

Brejk
Brejk

Reputation: 454

I guess that getParent() is not __toString, but it looks like it, because you try to concatenate it with the 'entity-' string. Therefore you have given object there, so you can access the id with the standard getter (e.g. getId() method)

So the parent object's id should be returned by $object->getParent()->getId()

Upvotes: 3

Related Questions