Skip to content

Instantly share code, notes, and snippets.

@nickvergessen
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickvergessen/8bb0d870942900bf591d to your computer and use it in GitHub Desktop.
Save nickvergessen/8bb0d870942900bf591d to your computer and use it in GitHub Desktop.
Namespace fixes

Hi there,

In the past week I cleanup the namespace usage of ownCloud a bit. In order to make our code better autoloadable, several few changes have been done.

Note: the first two sections have their old way still in place, but marked as deprecated. The new way should be used for new code and old code should be updated to this new way aswell, so we can remove the old/broken way at a later point (maybe in oC9 or oC10 or something like that)

The third section should not affect apps, since they should only be used in the core code.

The forth section should not require any changes.

cheers nickvergessen

Moved namespaced constants to class constants, so they can be autoloaded:

  • \OCP\PERMISSION_* constants have been deprecated in favour of \OCP\Constants::PERMISSION_*
  • \OCP\FILENAME_INVALID_CHARS constant has been deprecated in favour of \OCP\Constants::FILENAME_INVALID_CHARS
  • \OC_GROUP_BACKEND_* constants have been deprecated in favour of \OC_Group_Backend::*
  • \OC_GROUP_BACKEND_GET_DISPLAYNAME constant has been deprecated since it is no longer being used
  • \OC_USER_BACKEND_* constants have been deprecated in favour of \OC_Group_Backend::*

Moved namespaced functions to a class, so they can be autoloaded:

  • \OCP\image_path() has been deprecated in favour of \OCP\Template::image_path()
  • \OCP\mimetype_icon() has been deprecated in favour of \OCP\Template::mimetype_icon()
  • \OCP\preview_icon() has been deprecated in favour of \OCP\Template::preview_icon()
  • \OCP\publicPreview_icon() has been deprecated in favour of \OCP\Template::publicPreview_icon()
  • \OCP\human_file_size() has been deprecated in favour of \OCP\Template::human_file_size()
  • \OCP\relative_modified_date() has been deprecated in favour of \OCP\Template::relative_modified_date()
  • \OCP\simple_file_size() has been deprecated in favour of \OCP\Template::human_file_size()
  • \OCP\html_select_options() has been deprecated in favour of \OCP\Template::html_select_options()

Internal class and exceptions renamed (should not require changes in apps):

  • internal class \GET_TYPE class has been moved to \OC\Files #12451
  • internal exception \SyntaxException has been removed (use \UnexpectedValueException instead)
  • internal exception \DatabaseException has been renamed to \OC\DatabaseException
  • internal exception \DatabaseSetupException has been renamed to \OC\DatabaseSetupException

The following classes/interfaces have been moved to their own file, so they can be autoloaded (should not require changes in apps):

  • \OCP\Files\IHomeStorage moved from lib/public/files/storage.php to lib/public/files/ihomestorage.php
  • \OCP\Share_Backend moved from lib/public/share.php to lib/public/files/ihomestorage.php
  • \OCP\Share_Backend_File_Dependent moved from lib/public/share.php to lib/public/files/ihomestorage.php
  • \OCP\Share_Backend_Collection moved from lib/public/share.php to lib/public/files/ihomestorage.php
  • \OC\NaturalSort_DefaultCollator moved from lib/private/naturalsort.php to lib/private/naturalsort_defaultcollator.php
@MorrisJobke
Copy link

👍

@butonic
Copy link

butonic commented Dec 1, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment