Last active
November 2, 2015 19:34
-
-
Save kochen/425247bc02f395c6f3ff to your computer and use it in GitHub Desktop.
DOCman 2.0 Stable - add new document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$catid = 2; // the number of the specific category to assign the document to. | |
$fileinfo = array( /* an array of file info, including BASENAME and FILENAME */ ); | |
$datetime = date("Y-m-d H:i:s"); // current datetime | |
$user = KObjectMAnager::getInstance()->getObject('user'); // the Joomla user object | |
$controller = KObjectMAnager::getInstance()->getObject('com://admin/docman.controller.document'); | |
$controller->add(array( | |
docman_category_id => $catid, | |
storage_path => $fileinfo['filename'], | |
title => $fileinfo['basename'], | |
created_on => $datetime, | |
modified_on => $datetime, | |
modified_bycr => $user->id, | |
created_by => $user->id, | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If something goes wrong with this call an exception will be thrown at all times. Depending on what went wrong different exceptions are thrown and can be catched. We do not have a list of exceptions per method.
A. During development the adviced approach is to install our Joomla Vagrant Box which offers support for xdebug and makes full use of the build in framework debugger. This gives you complete stack tracing and exception output if something goes wrong.
To do so :
The last step is not required by useful for debugging fatal errors intead of exceptions. You get a complete stacktrace this way, which php doesn't provide out of the box.
B. During production it makes sense to catch exceptions that could occur. For example you can wrap the call in