示例#1
0
 /**
  * Constructor
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options.
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     //Add the toolbars
     $toolbars = (array) ObjectConfig::unbox($config->toolbars);
     foreach ($toolbars as $key => $value) {
         if (is_numeric($key)) {
             $this->attachToolbar($value);
         } else {
             $this->attachToolbar($key, $value);
         }
     }
 }
示例#2
0
 /**
  * Constructor
  *
  * @param ObjectConfig $object An optional ObjectConfig object with configuration options.
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     //Set the auto mixin state
     $this->_auto_mixin = $config->auto_mixin;
     //Add the behaviors
     $behaviors = (array) ObjectConfig::unbox($config->behaviors);
     foreach ($behaviors as $key => $value) {
         if (is_numeric($key)) {
             $this->attachBehavior($value);
         } else {
             $this->attachBehavior($key, $value);
         }
     }
 }
示例#3
0
 /**
  * Object constructor
  *
  * @param  ObjectConfig $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     if (is_null($config->command_chain)) {
         throw new \InvalidArgumentException('command_chain [CommandChainInterface] config option is required');
     }
     //Create a command chain object
     $this->_command_chain = $config->command_chain;
     //Enqueue the callback command
     if ($config->enable_callbacks) {
         $command = $this->getMixer()->mixin('lib:command.callback', $config);
         $this->getCommandChain()->enqueue($command, $config->callback_priority);
     }
     //Enqueue the event command
     if ($config->dispatch_events) {
         $command = $this->getMixer()->mixin('lib:command.event', $config);
         $this->getCommandChain()->enqueue($command, $config->event_priority);
     }
 }
示例#4
0
 /**
  * Object constructor
  *
  * @param ObjectConfig $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     if (is_null($config->event_dispatcher)) {
         throw new \InvalidArgumentException('event_dispatcher [EventDispatcherInterface] config option is required');
     }
     //Set the event dispatcher
     $this->_event_dispatcher = $config->event_dispatcher;
     //Add the event listeners
     foreach ($config->event_listeners as $event => $listener) {
         $this->addEventListener($event, $listener);
     }
     //Add the event handlers
     $subscribers = (array) ObjectConfig::unbox($config->event_subscribers);
     foreach ($subscribers as $key => $value) {
         if (is_numeric($key)) {
             $this->addEventSubscriber($value);
         } else {
             $this->addEventSubscriber($key, $value);
         }
     }
 }
示例#5
0
 /**
  * Object constructor
  *
  * @param   object  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     if (is_null($config->command_chain)) {
         throw new \InvalidArgumentException('command_chain [CommandChainInterface] config option is required');
     }
     //Create a command chain object
     $this->_command_chain = $config->command_chain;
     //Mixin the callback mixer if callbacks have been enabled
     if ($config->enable_callbacks) {
         $callback = new ObjectMixinCallback($config);
         //Mixin the callback mixin
         $mixin = $this->getMixer()->mixin('lib:object.mixin.callback', $config);
         //Enqueue the command in the mixer's command chain
         $this->getCommandChain()->enqueue($mixin, $config->callback_priority);
     }
     //Enqueue the event command with a lowest priority to make sure it runs last
     if ($config->dispatch_events) {
         $this->getMixer()->mixin('lib:event.mixin', $config);
         $command = $this->getCommandChain()->getObject('lib:command.event', array('event_dispatcher' => $this->getEventDispatcher()));
         $this->getCommandChain()->enqueue($command, $config->event_priority);
     }
 }
示例#6
0
 /**
  * Constructor.
  *
  * @param  ObjectConfig $config  A ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     //Set the object manager
     if (!$config->object_manager instanceof ObjectManagerInterface) {
         throw new \InvalidArgumentException('object_manager [ObjectManagerInterface] config option is required, "' . gettype($config->object_manager) . '" given.');
     } else {
         $this->__object_manager = $config->object_manager;
     }
     //Set the object identifier
     if (!$config->object_identifier instanceof ObjectIdentifierInterface) {
         throw new \InvalidArgumentException('object_identifier [ObjectIdentifierInterface] config option is required, "' . gettype($config->object_identifier) . '" given.');
     } else {
         $this->__object_identifier = $config->object_identifier;
     }
     parent::__construct($config);
     //Set the object config
     $this->__object_config = $config;
     //Set the command priority
     $this->_priority = $config->priority;
     //Automatically mixin the behavior
     if ($config->auto_mixin) {
         $this->mixin($this);
     }
 }
示例#7
0
 /**
  * Constructor
  *
  * @param ObjectConfig  $config  An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     //Set the chain break condition
     $this->_break_condition = $config->break_condition;
 }
示例#8
0
 /**
  * Object constructor
  *
  * @param ObjectConfig $config    An optional ObjectConfig object with configuration options
  */
 public function __construct(ObjectConfig $config)
 {
     parent::__construct($config);
     //Set the command priority
     $this->_priority = $config->callback_priority;
 }