public function fetchRelation(array $fields = array())
 {
     $requestAction = Requests::getRelationships($this->module->getModuleName(), $this->module->id, $this->relation->getDbName(), $this->relation->getModuleName(), $fields);
     $results = Request::call($requestAction);
     if ($this->relation->isCollection()) {
         return Converter::toModules($results, $this->relationModule);
     }
     return Converter::toModule($results->entry_list[0], $this->relationModule);
 }
예제 #2
0
 /**
  * @param $row
  * @param Module $module
  * @return Module
  */
 public static function toModule($row, Module $module)
 {
     $attributes = array();
     foreach ($row->name_value_list as $data) {
         $name = $data->name;
         $value = $data->value;
         $attributes[$name] = $value;
     }
     return $module->newInstance($attributes);
 }
예제 #3
0
 public function delete()
 {
     $attributes = Arrays::map($this->whereClauses, Functions::extract()->getParams());
     $queryInsert = new QueryInsert(Arrays::firstOrNull($attributes));
     $id = $queryInsert->into($this->module->getModuleName());
     return !is_null($id);
 }
예제 #4
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('attributes' => $attributes, 'hasMany' => array('accounts' => HasMany::module('Account'), 'contacts' => HasMany::module('Contact'), 'documents' => HasMany::module('Document'))));
 }
예제 #5
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('attributes' => $attributes));
 }
 public function __construct($attributes = array())
 {
     parent::__construct(array('attributes' => $attributes, 'belongsTo' => array('account' => BelongsTo::module('Account'), 'quote' => BelongsTo::module('AOS_Quotes'))));
 }
예제 #7
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('attributes' => $attributes, 'hasMany' => array('contacts' => HasMany::module('Contact'), 'leads' => HasMany::module('Lead'), 'opportunities' => HasMany::module('Opportunity'), 'documents' => HasMany::module('Document'), 'bugs' => HasMany::module('Bug'))));
 }
예제 #8
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('attributes' => $attributes, 'belongsTo' => array('account' => BelongsTo::module('Account')), 'hasMany' => array('bugs' => HasMany::module('Bug'))));
 }
 public function where($params = array())
 {
     $this->query->where(new WhereClause($this->module->getModuleDbName(), $params));
     return $this;
 }
예제 #10
0
 public function relatedWith(Module $module)
 {
     $result = Request::call(Requests::setRelationship($this->getModuleName(), $this->id, $module->getModuleDbName(), $module->id));
     if ($result->failed) {
         throw new Exception("Creating relationship failed");
     }
     return $result->created == 1;
 }