Пример #1
0
 public function __call($method, $arguments)
 {
     if (substr($method, 0, 3) === 'can') {
         $parts = KInflector::explode($method);
         array_shift($parts);
         array_unshift($parts, 'core');
         $permission = implode('.', $parts);
         return $this[$permission];
     }
     return parent::__call($method, $arguments);
 }
Пример #2
0
 /**
  * Constructor
  *
  * @param  KObjectConfig $config  An optional ObjectConfig object with configuration options.
  */
 public function __construct(KObjectConfig $config)
 {
     KObjectArray::__construct($config);
     $this->_identity_key = $config->identity_key;
     //Set the status
     if (isset($config->status)) {
         $this->_status = $config->status;
     }
     // Set the entity data
     if (isset($config->data)) {
         $this->_data = $config->data->toArray();
     } else {
         $this->_data = array();
     }
     //Set the status message
     if (!empty($config->status_message)) {
         $this->_status_message = $config->status_message;
     }
 }
Пример #3
0
 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * Function is also capable of checking is a behavior has been mixed succesfully
  * using is[Behavior] function. If the behavior exists the function will return 
  * TRUE, otherwise FALSE.
  *
  * @param  string 	The function name
  * @param  array  	The function arguments
  * @throws BadMethodCallException 	If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, array $arguments)
 {
     // If the method is of the form is[Bahavior] handle it.
     $parts = KInflector::explode($method);
     if ($parts[0] == 'is' && isset($parts[1])) {
         if (isset($this->_mixed_methods[$method])) {
             return true;
         }
         return false;
     }
     return parent::__call($method, $arguments);
 }
Пример #4
0
 public function __construct(KObjectConfig $config)
 {
     $config->append(array('data' => array('deleted' => false, 'internal' => false, 'attachments' => array(), 'downstreamDuplicates' => array(), 'upstreamDuplicates' => array(), 'attributes' => array())));
     parent::__construct($config);
 }
Пример #5
0
 /**
  * Unset an item in the array
  *
  * Required by interface ArrayAccess
  *
  * @param   int     $offset
  * @return  void
  */
 public function offsetUnset($offset)
 {
     KObjectArray::offsetUnset($offset);
 }
Пример #6
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   KObjectConfig $config An optional KObjectConfig object with configuration options
  */
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('model' => null));
     parent::_initialize($config);
 }
Пример #7
0
 /**
  * Prepares for rendering by loading classes
  *
  * @param	KConfig		$config		object of configurations
  */
 public function __construct(KConfig $config)
 {
     KLoader::load('lib.joomla.module.helper');
     $this->renderer = KFactory::get('lib.joomla.document')->loadRenderer('module');
     parent::__construct($config);
 }
Пример #8
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   KObjectConfig $config An optional ObjectConfig object with configuration options
  * @return  void
  */
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('parameters' => array()));
     parent::_initialize($config);
 }
Пример #9
0
 /**
  * Return an associative array of the data
  *
  * Skip the properties that start with an underscore as they are considered private
  *
  * @return array
  */
 public function toArray()
 {
     $data = parent::toArray();
     foreach (array_keys($data) as $key) {
         if (substr($key, 0, 1) === '_') {
             unset($data[$key]);
         }
     }
     return $data;
 }
Пример #10
0
 /**
  * Overridden offsetSet() method
  * 
  * All numerical array keys will be modified to start counting from zero 
  * while literal keys won't be touched.
  * 
  * @param 	int 	The offset of the item
  * @return 	object KDatabaseTRowsetAbstract
  */
 public function offsetUnset($offset)
 {
     //We need to use array_splice instead of unset to reset the keys
     array_splice($this->_data, $offset, 1);
     return parent::offsetUnset($offset);
 }
Пример #11
0
 /**
  * Constructor
  *
  * @param	array An optional associative array of configuration settings.
  */
 public function __construct(KConfig $options)
 {
     $this->_identifier = $options->identifier;
     parent::__construct($options);
     //$options  = $this->_initialize($options);
 }
Пример #12
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param   KObjectConfig $config An optional ObjectConfig object with configuration options
  */
 protected function _initialize(KObjectConfig $config)
 {
     $config->append(array('namespace' => '__' . $this->getIdentifier()->name, 'separator' => '.'));
     parent::_initialize($config);
 }
Пример #13
0
 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  * @return void
  */
 protected function _initialize(KConfig $config)
 {
     $config->append(array('data' => array()));
     parent::_initialize($config);
 }
Пример #14
0
 /**
  * Search the mixin method map and call the method or trigger an error
  *
  * This function implements a just in time mixin strategy. Available table behaviors are only mixed when needed.
  * Lazy mixing is triggered by calling KDatabaseRowsetTable::is[Behaviorable]();
  *
  * @param  string     $method    The function name
  * @param  array      $arguments The function arguments
  * @throws \BadMethodCallException     If method could not be found
  * @return mixed The result of the function
  */
 public function __call($method, $arguments)
 {
     if ($this->isConnected()) {
         $parts = KStringInflector::explode($method);
         //Check if a behavior is mixed
         if ($parts[0] == 'is' && isset($parts[1])) {
             if (!isset($this->_mixed_methods[$method])) {
                 //Lazy mix behaviors
                 $behavior = strtolower($parts[1]);
                 if ($this->getTable()->hasBehavior($behavior)) {
                     $this->mixin($this->getTable()->getBehavior($behavior));
                 } else {
                     return false;
                 }
             }
         }
     }
     return parent::__call($method, $arguments);
 }