/**
  * Binds a server end-point to a client end-point (internally, it creates a {@link __UIBinding} instance), allowing the synchronization from server to client but not the oposite way
  * It also set the bound direction to {@link __IEndPoing::BIND_DIRECTION_S2C} to both end-points 
  *
  * @param __IServerEndPoint $sep
  * @param __IClientEndPoint $cep
  */
 public function bindFromServerToClient(__IServerEndPoint $sep, __IClientEndPoint $cep)
 {
     $cep->setBoundDirection(__IEndPoint::BIND_DIRECTION_S2C);
     $sep->setBoundDirection(__IEndPoint::BIND_DIRECTION_S2C);
     $ui_binding = new __UIBinding($sep, $cep);
     $this->registerUIBinding($ui_binding);
 }
 public function addServerEndPoint(__IServerEndPoint $server_end_point)
 {
     $component_id = $server_end_point->getComponent()->getId();
     if (key_exists($component_id, $this->_binding_codes)) {
         $this->_binding_codes[$component_id] = array();
     }
     $server_end_point->getUIBinding;
 }
Esempio n. 3
0
 /**
  * Constructor method
  *
  * @param __IComponent &$component A reference to the component
  * @param string $property The property name
  */
 public function __construct(__IServerEndPoint $server_end_point, __IClientEndPoint $client_end_point)
 {
     $component_id = $server_end_point->getComponent()->getId();
     $client = substr(md5(serialize($client_end_point)), 0, 8);
     $this->_id = preg_replace('/^c/', 'ep-', $component_id) . '-' . $client;
     $this->setServerEndPoint($server_end_point);
     $this->setClientEndPoint($client_end_point);
 }
 public function synchronize(__IServerEndPoint &$server_end_point)
 {
     //if the server end-point is a valueholder, will synchronize
     //only if server and client values are different:
     if ($server_end_point instanceof __IValueHolder) {
         $value = $server_end_point->getValue();
         $current_value = $this->getValue();
         //if current value is different to new value
         //note that we are avoiding the case when comparing a null value with an empty string it
         //depends on how client submit values to server for empty fields
         if ($current_value !== $value && !(empty($current_value) && empty($value))) {
             $this->_value = $value;
             $this->setAsUnsynchronized();
         }
     } else {
         //if the server end-point is not a valueholder
         $this->setAsUnsynchronized();
     }
 }
 public function synchronize(__IServerEndPoint &$server_end_point)
 {
     if ($server_end_point instanceof __IValueHolder) {
         $this->setErrorMessage($server_end_point->getValue());
     }
 }