The primary factory for the SPS. This is a singleton and will control the loading and caching of the objects.

  • getSiteState() - Loads the SiteState object. If the current user has an active SiteState then it's loaded
  • getAllConditions() - Loads all of the condition. Returns a PreviewConditionCollection
  • getAllSetters() - Loads all of the Preview Setter plugins. Returns a PreviewSetterCollection
  • getCondition() - Load a Condition Plugin
  • geSetter() - Load a Setter Plugin
CommentFileSizeAuthor
#8 1623128.patch54 KBe2thex
#5 1623128.patch54.26 KBe2thex
#4 1623128.patch52.05 KBe2thex

Comments

indytechcook’s picture

Issue tags: +lsd-csi

adding tags

indytechcook’s picture

Assigned: Unassigned » indytechcook
Priority: Normal » Major
Issue tags: +lsd-csi sprint 1

Assigned to sprint 1

e2thex’s picture

Assigned: indytechcook » e2thex
e2thex’s picture

Status: Active » Needs review
StatusFileSize
new52.05 KB

Ok This has been flushed out a good around, The work on this part of the system also help to flush out so of the other parts of they system
Here is the overview of the Manager and it's use

/**
 * The Manager is the heart of the SPS system, taking inputs from different 
 * parts of the system and pushing them to the correct object for processing 
 * it can be orginized in to a few different sections
 *
 * Controller Access
 * The Manager managest access to drupal systems via different controllers. The 
 * SPS system use the manger to access there when they need access to Drupal
 *  .---------------------------------------------------------------.
 *  |                            Systems                            |
 *  '---------------------------------------------------------------'
 *                                  |
 *                                  v
 *                             .---------.
 *                             | Manager |
 *                             |---------|
 *                             '---------'
 * .---------------------------.    |
 * |     State Controller      |    |    .---------------------------.
 * |---------------------------|    |    |     Plugin Controller     |
 * | Controls the interface    |    |    |---------------------------|
 * | to the State cache        |<---|    | Controls the interface    |
 * | used to hold the current  |    '--->| to the plugin system      |
 * | site state                |    |    | holds method for getting  |
 * '---------------------------'    |    | pluign info and objects   |
 * .---------------------------.    |    '---------------------------'
 * |     Config Controller     |    |
 * |---------------------------|    |    .---------------------------.
 * | Controls the interface    |    |    |    Override Controller    |
 * | to the config for sps     |<---|    |---------------------------|
 * | hold the root condition   |    '--->| Controls the interface    |
 * | and infomation of plugins |         | to the store of the       |
 * '---------------------------'         | current overrides         |
 *                                       '---------------------------'
 *
 * Site State
 * THe Manager can create a site state object, and uses the State Controller 
 * to keep it around from page load to page load. When creating site state it 
 * hand off the Override Controller So that the Site state can Compile the 
 * override data and store it in the Override Controller
 *  
 *  @TODO this part of the system should be reviews when we start needing 
 *  access to the site state
 *
 *
 *
 * Preview Form
 * The Manager is the interface between the form hooks in the sps module 
 * and the Root Conditon that does most of the Form creation and processing 
 * .-----------------------------------------.
 * |    preview form hooks in sps.module     |
 * |-----------------------------------------|
 * | sps_preview_form()                      |
 * | sps_preview_form_validate()             |
 * | sps_preview_form_submit()               |
 * '-----------------------------------------'
 *                      |
 *                      |
 *                      v
 * .-----------------------------------------.
 * |                 Manager                 |
 * |-----------------------------------------|
 * | getPreviewForm($form, $form_state)      |
 * | validatePreviewForm($form, $form_state) |
 * | submitPreviewForm($form, $form_state)   |
 * '-----------------------------------------'
 *                      |
 *                      |
 *                      v
 * .-----------------------------------------.
 * |            Condition (Root)             |
 * |-----------------------------------------|
 * | getElement($form, $form_state)          |
 * | validateElement($form, $form_state)     |
 * | submitElement($form, $form_state)       |
 * '-----------------------------------------'
 * 
 *
 * Reactions
 * The manager is use as an interface for Drupal hooks that need to have a
 * reaction react
 *                    .-----------------------.   .--------------.
 * .--------------.   |        Manager        |   |   Reaction   |
 * | Drupal hooks |-->|-----------------------|-->|--------------|
 * '--------------'   | react($plugin, $data) |   | react($data) |
 *                    '-----------------------'   '--------------'
 *
 * Plugins
 * The Manager is a passthough to the plugin controller
 */

This is found in the Manager.php file

e2thex’s picture

StatusFileSize
new54.26 KB

There was no test for the react method i add those

indytechcook’s picture

Status: Needs review » Needs work

This is sweetness. Yeah for loads of tests!

+++ b/sps/lib/Drupal/sps/Manager.phpundefined
@@ -1,19 +1,365 @@
+function test_sps_get_config() {
+  $sps_config = array(
+    'conditions' => array(
+      'collection' => array(
+        'title' => 'Collection',
+        'widget' => 'collection_select',
+        'override' => 'view_collection_override',
+      ),
+      'date' => array(
+        'title' => 'Live Date',
+        'widget' => 'live_date',
+        'override' => 'view_live_date_override',
+      ),
+    ),
+  );
+  return $sps_config;

How do you feel about putting this in the sps_test module?

+++ b/sps/lib/Drupal/sps/Manager.phpundefined
@@ -1,19 +1,365 @@
   public function getSiteState() {
-    return new SiteState();
+    if($this->state_controller->is_set($this->state_controller_site_state_key)) {
+      return $this->state_controller->get($this->state_controller_site_state_key);
+    }

THe StateController is_set method should be isSet()

+++ b/sps/lib/Drupal/sps/Manager.phpundefined
@@ -1,19 +1,365 @@
+  /**
+  * Passthrough fro Drupal form to the correct condition used for validate a preview form
+  *
+  * @param $form
+  *   The form array passed to drupal validate functions
+  * @param $form_state
+  *   The form_state array passed to drupal validate functions
+  *
+  * @return ¶
+  *   Self

"fro" You spell like me!

+++ b/sps/lib/Drupal/sps/StorageController/CToolsObjectCache.phpundefined
@@ -0,0 +1,39 @@
+ protected static $obj = 'sps-ctools-object-cache';

What's this used for?

+++ b/sps/lib/Drupal/sps/StorageController/CToolsObjectCache.phpundefined
@@ -0,0 +1,39 @@
+   $_SESSION[$this->obj]['name'] = TRUE;

Should we try to abstract that part out? Not sure, may not be worth it, it just feels out of place there. Thoughts?

+++ b/sps/lib/Drupal/sps/StorageController/CToolsObjectCache.phpundefined
@@ -0,0 +1,39 @@
+ public function is_set($name);

Syntax isn't quite right here. Plus we need to change the method to isSet()

+++ b/sps/lib/Drupal/sps/StorageControllerInterface.phpundefined
@@ -1,10 +1,38 @@
+  /**
+   * Test if we have an object cached
+   *
+   * This should be less expensive then using get
+   *
+   * @param $name
+   *   A string name use for retrieval
+   * @return ¶
+   *   bool
+   */

Change to isSet

e2thex’s picture

as for the isSet it can not be used as a method name

php> class a { public function isSet($name) {}}
Multiline input has no syntactic completion:
PHP Parse error:  syntax error, unexpected T_ISSET, expecting T_STRING in Command line code on line 1

php> class a { public function is_set($name) {}}

php> 

per irc i will change it to exists

test_sps_get_config should just go away (it is not used)

The ctools cache stuff is not functional code, (making it functional is a task) i will comment out the code there so that is clear.

will patch shortly

e2thex’s picture

Status: Needs work » Needs review
StatusFileSize
new54 KB

Ok this patch contains all change mentioned in #7 and is commited in 1623128 branch

indytechcook’s picture

Status: Needs review » Fixed

Merged into 7.x-1.x

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.