I was looking for textbooks to better understand this, but I was out of luck. Please forgive the long explanation, but I want to make sure I explain well.
Firstly, I am fairly new to the MVC framework, although I did the training and studied as best as possible.
I navigate a live site into the Zend Framework model. So far, I have all the views in views / scripts / index / example.phtml.
Therefore, I use one IndexController, and I have code in each Action method for each page: IE public function exampleAction()
Since I did not know how to interact with the model, I put all the methods at the bottom of the controller (fat controller).
So basically I had a working site using View and Controller and without a model.
...
Now I am trying to learn how to enable the model.
So, I created View at:
view/scripts/calendar/index.phtml
I created a new controller at:
controller/CalendarControllers.php
and a new model with:
model/Calendar.php
The problem is that I think that I am not communicating correctly with the model (I am still new to OOP).
Can you look at my controller and model and tell me if you see a problem.
I need to return an array from runCalendarScript (), but I'm not sure if I can return the array to an object, how am I trying? I really don't understand how to βrunβ runCalendarScript () from a controller?
Thanks for any help! I cut most of the method brushes for the sake of brevity:
controller:
<?php class CalendarController extends Zend_Controller_Action { public function indexAction() { $finishedFeedArray = new Application_Model_Calendar(); $this->view->googleArray = $finishedFeedArray; } }
Model:
<?php class Application_Model_Calendar { public function _runCalendarScript(){ $gcal = $this->_validateCalendarConnection(); $uncleanedFeedArray = $this->_getCalendarFeed($gcal); $finishedFeedArray = $this->_cleanFeed($uncleanedFeedArray); return $finishedFeedArray; } //Validate Google Calendar connection public function _validateCalendarConnection() { ... return $gcal; } //extracts googles calendar object into the $feed object public function _getCalendarFeed($gcal) { ... return $feed; } //cleans the feed to just text, etc protected function _cleanFeed($uncleanedFeedArray) { $contentText = $this->_cleanupText($event); $eventData = $this->_filterEventDetails($contentText); return $cleanedArray; } //Cleans up all formatting of text from Calendar feed public function _cleanupText($event) { ... return $contentText; } //filterEventDetails protected function _filterEventDetails($contentText) { ... return $data; } }
Edit: Sorry, I don't know why my code formatting continues to look so ugly ...