From 6f6102c805198101fad36024b82692ebce20f2c8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Feb 2014 19:11:40 +0200 Subject: Add method chaining support to Calendar & Pagination libs --- system/libraries/Calendar.php | 10 +++++++--- system/libraries/Pagination.php | 4 +++- user_guide_src/source/changelog.rst | 2 ++ user_guide_src/source/libraries/calendar.rst | 6 ++++-- user_guide_src/source/libraries/pagination.rst | 3 ++- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index fc6599931..610b427cf 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -139,7 +139,7 @@ class CI_Calendar { * Accepts an associative array as input, containing display preferences * * @param array config preferences - * @return void + * @return CI_Calendar */ public function initialize($config = array()) { @@ -156,6 +156,8 @@ class CI_Calendar { { $this->next_prev_url = $this->CI->config->site_url($this->CI->router->class.'/'.$this->CI->router->method); } + + return $this; } // -------------------------------------------------------------------- @@ -513,7 +515,7 @@ class CI_Calendar { * Harvests the data within the template {pseudo-variables} * used to display the calendar * - * @return void + * @return CI_Calendar */ public function parse_template() { @@ -521,7 +523,7 @@ class CI_Calendar { if ($this->template === '') { - return; + return $this; } $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today'); @@ -537,6 +539,8 @@ class CI_Calendar { $this->temp[$val] = $this->temp[substr($val, 0, -6)]; } } + + return $this; } } diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index c6ffd03d4..f67cb47f8 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -314,7 +314,7 @@ class CI_Pagination { * Initialize Preferences * * @param array $params Initialization parameters - * @return void + * @return CI_Pagination */ public function initialize($params = array()) { @@ -342,6 +342,8 @@ class CI_Pagination { } } } + + return $this; } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a6fabe16b..f90fa42bf 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -284,6 +284,7 @@ Release Date: Not Released - :doc:`Calendar Library ` changes include: + - Added method chaining support. - Added configuration to generate days of other months instead of blank cells. - Auto set *next_prev_url* if it is empty and *show_prev_next* is set to TRUE. @@ -352,6 +353,7 @@ Release Date: Not Released - :doc:`Pagination Library ` changes include: + - Added method chaining support to ``initialize()`` method. - Added support for the anchor "rel" attribute. - Added support for setting custom attributes. - Deprecated usage of the "anchor_class" setting (use the new "attributes" setting instead). diff --git a/user_guide_src/source/libraries/calendar.rst b/user_guide_src/source/libraries/calendar.rst index aa10e941d..65a447a3d 100644 --- a/user_guide_src/source/libraries/calendar.rst +++ b/user_guide_src/source/libraries/calendar.rst @@ -202,7 +202,8 @@ Class Reference .. method:: initialize([$config = array()]) :param array $config: Configuration parameters - :rtype: void + :returns: CI_Calendar instance (method chaining) + :rtype: CI_Calendar Initializes the Calendaring preferences. Accepts an associative array as input, containing display preferences. @@ -280,7 +281,8 @@ Class Reference .. method:: parse_template() - :rtype: void + :returns: CI_Calendar instance (method chaining) + :rtype: CI_Calendar Harvests the data within the template ``{pseudo-variables}`` used to display the calendar. \ No newline at end of file diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 222436f46..ee12d9e6f 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -308,7 +308,8 @@ Class Reference .. method:: initialize([$params = array()]) :param array $params: Configuration parameters - :rtype: void + :returns: CI_Pagination instance (method chaining) + :rtype: CI_Pagination Initializes the Pagination class with your preferred options. -- cgit v1.2.3-24-g4f1b