Example #1
0
 /**
  * Constructor
  *
  * @param ObjectConfig $config An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     $this->registerCallback('after.read', array($this, 'lockEntity'));
     $this->registerCallback('after.save', array($this, 'unlockEntity'));
     $this->registerCallback('after.cancel', array($this, 'unlockEntity'));
 }
 /**
  * Get an object handle
  *
  * Only attach this behavior for form (application/x-www-form-urlencoded) POST requests.
  *
  * @return string A string that is unique, or NULL
  * @see execute()
  */
 public function getHandle()
 {
     $result = null;
     if ($this->getRequest()->isPost() && $this->getRequest()->getContentType() == 'application/x-www-form-urlencoded') {
         $result = parent::getHandle();
     }
     return $result;
 }
Example #3
0
 /**
  * Get an object handle
  *
  * Disable dispatcher persistency on non-HTTP requests, e.g. AJAX. This avoids changing the model state session
  * variable of the requested model, which is often undesirable under these circumstances.
  *
  * @return string A string that is unique, or NULL
  * @see execute()
  */
 public function getHandle()
 {
     $result = null;
     if ($this->getRequest()->isGet() && !$this->getRequest()->isAjax()) {
         $result = parent::getHandle();
     }
     return $result;
 }
Example #4
0
 /**
  * Constructor
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     $this->registerCallback('before.read', array($this, 'setReferrer'));
     $this->registerCallback('after.apply', array($this, 'lockReferrer'));
     $this->registerCallback('after.read', array($this, 'unlockReferrer'));
     $this->registerCallback('after.save', array($this, 'unsetReferrer'));
     $this->registerCallback('after.cancel', array($this, 'unsetReferrer'));
 }
 /**
  * Constructor
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     $this->registerCallback('after.read', array($this, 'lockResource'));
     $this->registerCallback('after.save', array($this, 'unlockResource'));
     $this->registerCallback('after.cancel', array($this, 'unlockResource'));
     if ($this->getRequest()->getFormat() == 'html') {
         $this->registerCallback('before.read', array($this, 'setReferrer'));
         $this->registerCallback('after.apply', array($this, 'lockReferrer'));
         $this->registerCallback('after.read', array($this, 'unlockReferrer'));
         $this->registerCallback('after.save', array($this, 'unsetReferrer'));
         $this->registerCallback('after.cancel', array($this, 'unsetReferrer'));
     }
 }
Example #6
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  ObjectConfig $config A ObjectConfig object with configuration options
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('cookie_name' => 'referrer', 'cookie_path' => $this->getObject('request')->getBaseUrl()->toString(HttpUrl::PATH)));
     parent::_initialize($config);
 }
Example #7
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param  ObjectConfig $config An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     $config->append(array('priority' => CommandChain::PRIORITY_HIGH, 'auto_mixin' => true));
     parent::_initialize($config);
 }
 /**
  * Mixin Notifier
  *
  * This function is called when the mixin is being mixed. It will get the mixer passed in.
  *
  * @param ObjectMixable $mixer The mixer object
  * @return void
  */
 public function onMixin(ObjectMixable $mixer)
 {
     parent::onMixin($mixer);
     //Mixin the permission
     $permission = clone $mixer->getIdentifier();
     $permission->path = array('dispatcher', 'permission');
     if ($permission !== $this->getPermission()) {
         $this->setPermission($mixer->mixin($permission));
     }
 }
Example #9
0
 /**
  * Mixin Notifier
  *
  * This function is called when the mixin is being mixed. It will get the mixer passed in.
  *
  * @param ObjectMixable $mixer The mixer object
  * @return void
  */
 public function onMixin(ObjectMixable $mixer)
 {
     parent::onMixin($mixer);
     //Create and mixin the permission if it's doesn't exist yet
     if (!$this->_permission instanceof ControllerPermissionInterface) {
         $permission = $this->_permission;
         if (!$permission || is_string($permission) && strpos($permission, '.') === false) {
             $identifier = $mixer->getIdentifier()->toArray();
             $identifier['path'] = array('controller', 'permission');
             if ($permission) {
                 $identifier['name'] = $permission;
             }
             $permission = $this->getIdentifier($identifier);
         }
         if (!$permission instanceof ObjectIdentifierInterface) {
             $permission = $this->getIdentifier($permission);
         }
         $this->_permission = $mixer->mixin($permission);
     }
 }
Example #10
0
 /**
  * Initializes the default configuration for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options.
  * @return void
  */
 protected function _initialize(ObjectConfig $config)
 {
     parent::_initialize($config);
     $config->append(array('toolbars' => array()));
 }