public function directoryName($object, PropertyMapping $mapping) { if ($object instanceof Document) { return Helper::codau2khongdau($this->getParentPath($object->getCategoryId()), true); } elseif ($object instanceof Project) { return Helper::codau2khongdau($this->getParentPath($object->getCategory()) . $object->getName(), true); } return ''; }
protected function getUploadDir() { // get rid of the __DIR__ so it doesn't screw up // when displaying uploaded doc/image in the view. $category = $this->getCategoryId(); $path = $category->getName(); while (null !== $category->getParent() && $category->getParent()->getName() != '') { $category = $category->getParent(); $path = $category->getName() . '/' . $path; } return 'documents/' . Helper::codau2khongdau($path); }