Folder samples
Basics
On most methods you'll see parameter named "fldId". The value of this parameter can be some valid folder UUID or path.
Example of fldId:
- Using UUID -> "6e86cc0b-bc9a-4c51-8296-e9d4e749e449";
- Using path -> "/okm:root/SDK4PHP/test"
Methods
createFolder
Description:
Method | Return values | Description |
---|---|---|
createFolder(Folder $fld) |
Folder |
Creates a new folder and return as a result an object Folder. |
The variable path into the parameter $fld, must be initializated. It indicates the folder path into OpenKM.
The other variables of a Folder ( fld ) will not take any effect on the folder creation. We suggest using the method below createFolderSimple rather this one. |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Folder;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testCreateFolder() {
try {
$fld = new Folder();
$fld->setPath("/okm:root/SDK4PHP/test");
$folder = $this->ws->createFolder($fld);
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testCreateFolder();
?>
createFolderSimple
Description:
Method | Return values | Description |
---|---|---|
createFolderSimple($fldPath) |
Folder |
Creates a new folder and returns as a result an object Folder. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Folder;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testCreateFolderSimple() {
try {
$folder = $this->ws->createFolderSimple("/okm:root/SDK4PHP/test");
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testCreateFolderSimple();
?>
getFolderProperties
Description:
Method | Return values | Description |
---|---|---|
getFolderProperties($fldId) |
Folder |
Returns the folder properties. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Folder;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetFolderProperties() {
try {
$folder = $this->ws->getFolderProperties("/okm:root/SDK4PHP/test");
var_dump($folder);
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testGetFolderProperties();
?>
deleteFolder
Description:
Method | Return values | Description |
---|---|---|
deleteFolder($fldId) |
void |
Deletes a folder. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testDeleteFolder() {
try {
$this->ws->deleteFolder("/okm:root/SDK4PHP/test");
echo 'delete Folder';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testDeleteFolder();
?>
renameFolder
Description:
Method | Return values | Description |
---|---|---|
renameFolder($fldId, $newName) |
void |
Renames a folder. |
Parameters: $newName string type is the new name for the Folder |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testRenameFolder() {
try {
// Exists folder /okm:root/SDK4PHP/test
$this->ws->renameFolder("/okm:root/SDK4PHP/test","renamedFolder");
// Folder has renamed to /okm:root/SDK4PHP/renamedFolder
echo 'rename Folder';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testRenameFolder();
?>
moveFolder
Description:
Method | Return values | Description |
---|---|---|
moveFolder($fldId, $dstId) |
void |
Moves a folder into a folder or record. |
Parameters: $dstId string type is the uuid or path of the Folder or record |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Folder;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testMoveFolder(){
try {
// Exists folder /okm:root/SDK4PHP/test
$this->ws->moveFolder("/okm:root/SDK4PHP/test","/okm:root/SDK4PHP/tmp");
// Folder has moved to /okm:root/SDK4PHP/tmp/test
echo 'move folder';
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testMoveFolder();
?>
getFolderChildren
Description:
Method | Return values | Description |
---|---|---|
getFolderChildren($fldId) |
array |
Returns an array of all folder which their parent is fldId. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Folder;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetFolderChildren(){
try {
$folders = $this->ws->getFolderChildren("/okm:root/SDK4PHP");
foreach ($folders as $folder) {
var_dump($folder);
}
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testGetFolderChildren();
?>
isValidFolder
Description:
Method | Return values | Description |
---|---|---|
isValidFolder($fldId) |
Boolean |
Returns a boolean that indicates if the node is a folder or not. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testIsValidFolder(){
try {
// Return false
var_dump($this->ws->isValidFolder("/okm:root/SDK4PHP/logo.png"));
// Return true
var_dump($this->ws->isValidFolder("/okm:root/SDK4PHP"));
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testIsValidFolder();
?>
getFolderPath
Description:
Method | Return values | Description |
---|---|---|
getFolderPath($uuid) |
String |
Converts folder UUID to folder path. |
Parameters: |
Example:
<?php
include '../src/openkm/OpenKM.php';
use openkm\OKMWebservices;
use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Folder;
class ExampleFolder {
const HOST = "http://localhost:8080/OpenKM/";
const USER = "okmAdmin";
const PASSWORD = "admin";
private $ws;
public function __construct() {
$this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
}
public function testGetFolderPath(){
try {
var_dump($this->ws->getFolderPath("6e86cc0b-bc9a-4c51-8296-e9d4e749e449"));
} catch (Exception $e) {
var_dump($e);
}
}
}
$openkm = new OpenKM(); //autoload
$exampleFolder = new ExampleFolder();
$exampleFolder->testGetFolderPath();
?>