6 * This is a helper class, that should aid in getting collections classes setup.
7 * Most of its methods are implemented, and throw permission denied exceptions
11 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12 * @author Evert Pot (http://www.rooftopsolutions.nl/)
13 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
15 abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_ICollection {
18 * Returns a child object, by its name.
20 * This method makes use of the getChildren method to grab all the child
21 * nodes, and compares the name.
22 * Generally its wise to override this, as this can usually be optimized
24 * This method must throw Sabre_DAV_Exception_NotFound if the node does not
28 * @throws Sabre_DAV_Exception_NotFound
29 * @return Sabre_DAV_INode
31 public function getChild($name) {
33 foreach($this->getChildren() as $child) {
35 if ($child->getName()==$name) return $child;
38 throw new Sabre_DAV_Exception_NotFound('File not found: ' . $name);
43 * Checks is a child-node exists.
45 * It is generally a good idea to try and override this. Usually it can be optimized.
50 public function childExists($name) {
54 $this->getChild($name);
57 } catch(Sabre_DAV_Exception_NotFound $e) {
66 * Creates a new file in the directory
68 * Data will either be supplied as a stream resource, or in certain cases
69 * as a string. Keep in mind that you may have to support either.
71 * After succesful creation of the file, you may choose to return the ETag
72 * of the new file here.
74 * The returned ETag must be surrounded by double-quotes (The quotes should
75 * be part of the actual string).
77 * If you cannot accurately determine the ETag, you should not return it.
78 * If you don't store the file exactly as-is (you're transforming it
79 * somehow) you should also not return an ETag.
81 * This means that if a subsequent GET to this new file does not exactly
82 * return the same contents of what was submitted here, you are strongly
83 * recommended to omit the ETag.
85 * @param string $name Name of the file
86 * @param resource|string $data Initial payload
89 public function createFile($name, $data = null) {
91 throw new Sabre_DAV_Exception_Forbidden('Permission denied to create file (filename ' . $name . ')');
96 * Creates a new subdirectory
99 * @throws Sabre_DAV_Exception_Forbidden
102 public function createDirectory($name) {
104 throw new Sabre_DAV_Exception_Forbidden('Permission denied to create directory');