Exemple #1
0
 /**
  * Adds a resource to the set the set of resources.
  *
  * @param string|array $config
  */
 public function insert($config)
 {
     if (is_string($config)) {
         $config = array('name' => $config);
     }
     $config = new KConfig($config);
     if (empty($config->link) && !empty($this->_resources)) {
         $name = KInflector::singularize($this->main()->getName());
         $config->link = array('child' => $name . '_id', 'parent' => 'id');
     }
     $config->append(array('columns' => $this->_store->getColumns($config->name)));
     $resource = new AnDomainResource($config);
     $this->_resources[$resource->getAlias()] = $resource;
     return $this;
 }
Exemple #2
0
 /**
  * Adds a resource to the set the set of resources 
  *
  * @param  string|array $config
  * @return void
  */
 public function insert($config)
 {
     if (is_string($config)) {
         $config = array('name' => $config);
     }
     $config = new KConfig($config);
     //if more than one resource is added but there's no
     //link then try to infer the link by using the main
     //table {main_table_name}_id
     if (empty($config->link) && !empty($this->_resources)) {
         $parts = explode('_', KInflector::singularize($this->main()->getName()));
         $config->link = array('child' => $parts[1] . '_id', 'parent' => 'id');
     }
     $config->append(array('columns' => $this->_store->getColumns($config->name)));
     $resource = new AnDomainResource($config);
     $this->_resources[$resource->getAlias()] = $resource;
     return $this;
 }