Example #1
0
 /**
  * An MVC page must have controller and action set
  *
  * @return void
  * @throws Zym_Navigation_Page_InvalidException  if page is invalid
  */
 protected function _validate()
 {
     if (!isset($this->_controller)) {
         $msg = 'Page controller is not set';
     } elseif (!isset($this->_action)) {
         $msg = 'Page action is not set';
     }
     if (isset($msg)) {
         require_once 'Zym/Navigation/Page/InvalidException.php';
         throw new Zym_Navigation_Page_InvalidException($msg);
     } else {
         parent::_validate();
     }
 }
Example #2
0
 /**
  * Tests the toArray() method
  *
  */
 public function testToArrayMethod()
 {
     $options = array('label' => 'foo', 'action' => 'index', 'controller' => 'index', 'module' => 'test', 'id' => 'my-id', 'class' => 'my-class', 'title' => 'my-title', 'target' => 'my-target', 'position' => 100, 'active' => true, 'visible' => false, 'foo' => 'bar', 'meaning' => 42);
     $page = new Zym_Navigation_Page_Mvc($options);
     $toArray = $page->toArray();
     $options['reset_params'] = true;
     $options['route'] = 'default';
     $options['params'] = array();
     //$this->assertEquals($options, $toArray);
     $this->assertEquals(array(), array_diff_assoc($options, $page->toArray()));
 }
Example #3
0
 * Dispatched request:
 * - module:     default
 * - controller: index
 * - action:     index
 */
$page1 = new Zym_Navigation_Page_Mvc(array('label' => 'foo', 'action' => 'index', 'controller' => 'index'));
$page2 = new Zym_Navigation_Page_Mvc(array('label' => 'foo', 'action' => 'bar', 'controller' => 'index'));
$page1->isActive();
// returns true
$page2->isActive();
// returns false
/*
 * Dispatched request:
 * - module:     blog
 * - controller: post
 * - action:     view
 * - id:         1337
 */
$page = new Zym_Navigation_Page_Mvc(array('label' => 'foo', 'action' => 'view', 'controller' => 'post', 'module' => 'blog'));
// returns true, because request has the same module, controller and action
$page->isActive();
/*
 * Dispatched request:
 * - module:     blog
 * - controller: post
 * - action:     view
 */
$page = new Zym_Navigation_Page_Mvc(array('label' => 'foo', 'action' => 'view', 'controller' => 'post', 'module' => 'blog', 'id' => null));
// returns false, because page requires the id param to be set in the request
$page->isActive();
// returns false
Example #4
0
<?php

// the following route is added to the ZF router
Zend_Controller_Front::getInstance()->getRouter()->addRoute('article_view', new Zend_Controller_Router_Route('a/:id', array('module' => 'news', 'controller' => 'article', 'action' => 'view', 'id' => null)));
// a page is created with a 'route' option
$page = new Zym_Navigation_Page_Mvc(array('label' => 'A news article', 'route' => 'article_view', 'params' => array('id' => 42)));
// returns: /a/42
$page->getHref();
Example #5
0
 /**
  * Sets action helper for assembling URLs
  *
  * @param Zend_Controller_Action_Helper_Url $uh
  */
 public static function setUrlHelper(Zend_Controller_Action_Helper_Url $uh)
 {
     self::$_urlHelper = $uh;
 }