public function isInContainer(Container $c) { if ($this->getType() == c\T::SITE) { throw new e\WrongAssetTypeException(c\M::SITE_NO_PARENT_CONTAINER); } return $c->getId() == $this->getParentContainerId(); }
public function __construct(Container $container) { if ($container == NULL) { throw new e\NullAssetException(c\M::NULL_CONTAINER); } $this->root = $container; $root_children = $container->getChildren(); $this->has_children = count($root_children) > 0; if ($this->has_children) { $this->children = array(); foreach ($root_children as $root_child) { if ($root_child->getType() == $container->getType()) { $class_name = c\T::$type_class_name_map[$container->getType()]; $class_name = Asset::NAME_SPACE . "\\" . $class_name; $this->children[] = new AssetTree($class_name::getAsset($this->root->getService(), $container->getType(), $root_child->getId())); } else { $this->children[] = $root_child; } } } }
public function __construct(aohs\AssetOperationHandlerService $service, \stdClass $identifier) { parent::__construct($service, $identifier); $this->processMetadata(); }
public function moveAsset(Asset $a, Container $new_parent) { if ($a == NULL || $new_parent == NULL) { throw new e\NullAssetException(S_SPAN . c\M::NULL_ASSET . E_SPAN); } if ($a->getParentContainer()->getId() == $new_parent->getId()) { throw new e\RenamingFailureException(S_SPAN . c\M::SAME_CONTAINER . E_SPAN); } $this->service->move($a->getIdentifier(), $new_parent->getIdentifier(), $a->getName(), false); if (!$this->service->isSuccessful()) { throw new e\RenamingFailureException(S_SPAN . c\M::RENAME_ASSET_FAILURE . E_SPAN); } return $this; }
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()); } }