public function copy(Container $parent, $new_name) { if ($new_name == "") { throw new e\EmptyNameException(c\M::EMPTY_NAME); } $service = $this->getService(); $self_identifier = $service->createId($this->getType(), $this->getId()); $service->copy($self_identifier, $parent->getIdentifier(), $new_name, false); if ($service->isSuccessful()) { $parent->reloadProperty(); // get info of new child $parent = $parent->getProperty(); $children = $parent->children->child; $child_count = count($children); if ($child_count == 1) { $children = array($children); } // look for the new child foreach ($children as $child) { $child_path = $child->path->path; $child_path_array = explode('/', $child_path); if (in_array($new_name, $child_path_array)) { $child_found = $child; break; } } // get the digital id of child $child_id = $child_found->id; // return new block object return Asset::getAsset($service, $this->getType(), $child_id); } else { throw new e\CopyErrorException(c\M::COPY_ASSET_FAILURE . $service->getMessage()); } }